VFS object
VFS global object.
Syntax
A VFS global object is created for you and only this object
can exist in the application. It is named VFS and is globally
accessible.
Parameters
none.
Property Of
global name space.
Implemented In
ECMerge 2.1
Description
The VFS object let you realize a few basic operations
on files and folders currently. Files and folders are pointed
to by URL
objects.
Properties
| Property |
Description |
| kRead |
Integer. Used to indicate that a file is open for
reading only |
| kWrite |
Integer. Used to indicate that a file is open for
writing only |
| kReadWrite |
Integer. Used to indicate that a file is open for
both reading and wirting |
| kAppend |
Integer. Used to indicate that a file is open to
write at end |
| kCreateAlways |
Integer. Used to indicate that a file is always
opened empty, ignoring its presence and/or old
content |
| kCreateNew |
Integer. Used to indicate that a file is only
added |
| kOpenExisting |
Integer. Used to indicate that a file is only opened
(i.e. not created) |
| kOpenAlways |
Integer. Used to indicate that a file is opened if it
is there, created if it was not |
| kTruncateExisting |
Integer. Used to indicate that a file is only opened,
but emptied at once |
| kShareRead |
Integer. Used to indicate that a file is open,
allowing others to read at the same time |
| kShareWrite |
Integer. Used to indicate that a file is open,
allowing others to write at the same time |
| kShareAll |
Integer. Used to indicate that a file is open
,allowing all accesses |
| kShareNone |
Integer. Used to indicate that a file is open, but
none else should access the file |
| kTemporary |
Integer. Used to indicate that a file is open as a
temporary file |
| kAutoAbort |
Integer. Used to indicate that a file is open, but it
should be deleted unless a validation occurs
successfuly |
Methods
dir
get_temporary_file_name
load_text
save_text
Examples
see functions samples.
See Also
URL
object.

Method dir
Syntax
function dir ( url, re )
returns an Array of VFS.Metadata
objects.
Parameters
url. URL
object. URL toward the directory to list
re. RegExp object. Only entries matching this regular
expression are returned. If omitted, all entires are
returned
Method Of
VFS
object.
Implemented In
ECMerge 2.1
Description
Lists the directory designed by url and returns the
entries as an Array of metadata.
Examples
Example 1.
Dumps as XML the metadata of all the elements under the root
of the file system:
var metadata_array = VFS.dir ("/");
log ( metadata_array.join ( ) );
See Also
URL
object, VFS
object, VFS.Metadata
object

Method
get_temporary_file_name
Syntax
function get_temporary_file_name ( )
returns a String
Parameters
none.
Method Of
VFS
object.
Implemented In
ECMerge 2.1
Description
Returns the name for a temporary file. Usually an
empty file is created with this name during the execution
of this call, to avoid another call returning the same
value.
Examples
Example 1.
Prints 10 different temporary file names:
for (var idxtfn=0; idxtfn<10; ++idxtfn)
log ( VFS.get_temporary_file_name ()
);
See Also
VFS
object

Method
load_text
Syntax
function load_text (url, encoding, detect, at_most)
returns a String
Parameters
url. URL
object. URL pointing to the text file to read.
encoding. Encoding string. Encoding to use (see
'detect'). If undefined or omitted, load_text uses default
system encoding.
detect. Boolean. True when signatures detection is enabled
(currently Unicode signatures), hence encoding is a 'default'.
False to ignore signatures, therefore, encoding is then always
used. If undefined or omitted, true is assumed.
at_most. Integer. Number of bytes which you accept to read from
the file. If undefined or omitted, the whole file is read.
Method Of
VFS
object.
Implemented In
ECMerge 2.1
Description
Reads a text file and returns its content as a string.
Examples
Example 1.
Displays a message with the content of a file:
alert ( VFS.load_text ( "/etc/hosts" ) );
See Also
VFS
object

Method
save_text
Syntax
function save_text ( url, text, encoding, save_signature,
creation_flags)
Parameters
url. URL
object. URL pointing where to save the text.
text. String. Text to save
encoding. Encoding string. Encoding to use to save the text. If
undefined or omitted, default system encoding is used.
save_signature. Boolean. True when the appropriate signature
for encoding should be written. If undefined or
omitted, true is assumed.
creation_flags. Integer. A bitwise-OR of VFS.k??? constants. If
undefined or omitted,
VFS.kCreateNew|VFS.kReadWrite|VFS.kShareNone is
assumed.
Method Of
VFS
object.
Implemented In
ECMerge 2.1
Description
Saves a text to a URL location, in a given encoding.
Examples
Example 1.
Saves a text file:
var text = "hello world!";
VFS.save_text ("/tmp/mytest.txt"', text, "UTF8", true,
VFS.kCreateAlways|VFS.kWrite);
See Also
VFS
object, URL
object
