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.
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
Methods inherited from: Concept
cloneConcept, extendsConcept, fromXML, getAllInheritedConcepts, getConceptAttribute, getConceptAttributeField, getConceptAttributeFields, getConceptAttributes, getConceptConstructors, getConceptElement, getConceptElementField, getConceptElementFields, getConceptElements, getConceptLabel, getConceptMethod, getConceptMethods, getConceptOperators, getConceptType, getErrorHandler, getInheritedConcepts, getResourceURI, hasConceptAttribute, hasConceptElement, hasConceptMethod, hasPath, isHidden, loadContent, setConceptLabel, setErrorHandler, setHidden, setShowEmpty, showEmpty, toTXT, toXML, setResourceURI |
|
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.
Label: | length |
Type: | Integer |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
The size of this file.
Label: | url |
Type: | String |
Is Static: | false |
Is Hidden: | false |
Show Empty: | true |
The URI of this file. Full path+file name.
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.
Parameters: |
$pathname : | A pathname string. |
|
Creates a new File concept from the pathname given as parameter.
Returns true if the file denoted by the URL exists and can be read,
false otherwise.
$file = File.create("file:///home/guest/notes.txt")
print $file.canRead
-- the result is --
true
Returns true if the file denoted by the URL exists and the application
can write in it, false otherwise.
$file = File.create("file:///home/guest/notes.txt")
print $file.canWrite
-- the result is --
true
Deletes the file or directory denoted by this abstract pathname. If it
is a directory then it must be empty in order to succeed.
$file = File.create("file:///home/guest/notes.txt")
print $file.exists
$file.delete
print $file.exists
-- the result is --
true
false
Returns true if the file denoted by the URL exists and, false otherwise.
$file = File.create("file:///home/guest/notes.txt")
print $file.exists
-- the result is --
true
Exceptions: |
fileOperationException :
(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.
$file = File.create("file:///home/guest/test.txt")
print $file.getContent
-- the result is --
This is a test.
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 '\'.
print File.getSeparator
-- the result is --
/
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.
$file = File.create("file:///home/guest/")
print $file.getLinks
-- the result is --
file:/home/guest/tmp/
file:/home/guest/test.txt
Returns true if the file denoted by the URL exists and is a file, false
otherwise.
$file = File.create("file:///home/guest/")
print $file.isFile
-- the result is --
false
Returns true if the file denoted by the URL exists and is hidden, false otherwise.
$file = File.create("file:///home/guest/test.txt")
print $file.isHidden
-- the result is --
false
Parameters: |
$pathname : | A pathname string. |
|
Creates any directory marked by the abstract path name, including any
necessary, but not existent parent directory.
File.mkdir("file:///home/guest/docs/")
$file = File.create("file:///home/guest/")
print $file.getLinks
-- the result is --
file:/home/borzy/docs/
file:/home/guest/tmp/
file:/home/guest/test.txt
Parameters: |
$url : | URL with the new file name. |
|
Returns true if the file can be renamed to the given name, false
otherwise.
$dir = File.create("file:///home/guest/")
print $dir.getLinks
$file = File.create("file:///home/guest/test.txt")
$file.rename("/home/guest/text.log")
print $dir.getLinks
-- the result is --
file:/home/guest/tmp/
file:/home/guest/test.txt
file:/home/guest/tmp/
file:/home/guest/text.log
Parameters: |
$newValue : |
Value to be set. The $value must be a String or a ByteArray concept. |
|
Exceptions: |
fileOperationException :
(Error) | If unable to write a file. |
Sets this File content to the specified value.
$file = File.create("file:///home/guest/test.txt")
print $file.getContent
$file.setContent("This is the new content.")
print $file.getContent
-- the result is --
This is a test.
This is the new content.
Sets the file's attribute to the value of the logical parameter true or
false.
$file = File.create("file:///home/guest/test.txt")
print $file.setReadOnly
-- the result is --
true