mn8 Language Reference | Index    

File

SUMMARY: ATTRIBUTES SUMMARY  ELEMENTS SUMMARY  CONSTRUCTORS SUMMARY  NO OPERATORS  METHODS SUMMARYDETAIL: ATTRIBUTE DETAILS  ELEMENT DETAILS  CONSTRUCTOR DETAILS  NO OPERATORS  METHOD DETAILS

Description

The File concept is an abstraction of the regular operating system dependent file or directory. It is returned by the File, FTP protocol handlers and also if the content type is unknown by the HTTP protocol handler.

Usage

The URI of this file. Full path+file name.

            $myFile = File.create("file:///home/jon/xfile.txt")
            PRINT $myFile@url
                file:///home/jon/xfile.txt
        
The size of this file.
            PRINT $myFile.length
                1024
        

Returns the MIME type of the file. If the type is unknown to the system the "application/octet-stream" is returned.

            $myFile = File.create("file:///home/guest/diary.txt")
            PRINT $myFile@contentType
                text/plain
        

Version: 0.1
Authors:Remus Pereni (http://neuro.nolimits.ro)
Inherits: Concept

Attribute List

 @contentType TYPEOF String LABEL "contentType"
 @length TYPEOF Integer LABEL "length"
 @url TYPEOF String LABEL "url"
top

Element List

 content TYPEOF String LABEL "content"
top

Constructor List

create (String $pathname)
top

Method List

LogicalcanRead
LogicalcanWrite
Logicaldelete
Logicalexists
StringgetContent
static StringgetSeparator
SeriesgetLinks
LogicalisFile
LogicalisHidden
static Logicalmkdir (String $pathname)
LogicalreadContent
Logicalrename (String $newName)
LogicalsetContent (Concept $newValue)
LogicalsetReadOnly
top
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getConceptsAtPath, getErrorHandler, getInheritedConcepts, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML

Detailed Attribute Info

@contentType

Label:contentType
Type:String
Is Static:false
Is Hidden:false
Show Empty:true

Returns the MIME type of the file. If the type is unknown to the system the "application/octet-stream" is returned.

top

@length

Label:length
Type:Integer
Is Static:false
Is Hidden:false
Show Empty:true

The size of this file.

top

@url

Label:url
Type:String
Is Static:false
Is Hidden:false
Show Empty:true

The URI of this file. Full path+file name.

top

Detailed Element Info

content

Label:content
Type:String
Is Static:false
Is Hidden:false
Is Multi:false
Show Empty:true

Returns the content of the file as non escaped (`line1\nline2`) String.

top

Detailed Constructor Info

create (String $pathname)
Parameters:
$pathname :A pathname string.

Creates a new File concept from the pathname given as parameter.

top

Detailed Method Info

canRead
Returns: Logical

Returns true if the file denoted by the URL exists and can be read, false otherwise.

top
canWrite
Returns: Logical

Returns true if the file denoted by the URL exists and the application can write in it, false otherwise.

top
delete
Returns: Logical

Deletes the file or directory denoted by this abstract pathname. If it is a directory then it must be empty in order to succeed.

top
exists
Returns: Logical

Returns true if the file denoted by the URL exists and, false otherwise.

top
getContent
Returns: String
Exceptions:
fileOperationFailed :
(Error)
If unable to read a file.

Returns a Series with the content of the file denoted by the abstract path name. The content is wrapped in the Series respecting the Content Model.

top
static getSeparator
Returns: String

The system-dependent default name-separator character. This field is initialized to contain the first character of the value of the system property file.separator. On UNIX systems the value of this field is '/'; on Win32 systems it is '\'.

top
getLinks
Returns: Series

If the file denoted by the URL is a directory then returns all the URL's of the files and directories it contains as a Series. If it is a file then returns Nil.

top
isFile
Returns: Logical

Returns true if the file denoted by the URL exists and is a file, false otherwise.

top
isHidden
Returns: Logical

Returns true if the file denoted by the URL exists and is hidden, false otherwise.

top
static mkdir (String $pathname)
Parameters:
$pathname :A pathname string.
Returns: Logical

Creates any directory marked by the abstract path name, including any necessary, but not existent parent directory.

top
readContent
Returns: Logical
Exceptions:
fileOperationFailed :
(Error)
If unable to read a file.

Returns true if this File content has been readed successfully, false otherwise.

top
rename (String $newName)
Parameters:
$newName :New File name.
Returns: Logical

Returns true if the file can be renamed to the given name, false otherwise.

top
setContent (Concept $newValue)
Parameters:
$newValue :Value to be set.
Returns: Logical
Exceptions:
fileOperationFailed :
(Error)
If unable to write a file.

Sets this File content to the specified value.

top
setReadOnly
Returns: Logical

Sets the file's attribute to the value of the logical parameter true or false.

top