Water 5-System Interfaces-FilesystemCreates a file resource from a path
Contract| Parameter key | Default value | Type | | a_uri | opt | | contract | opt | | type | opt | | a_response | null | | http_message | opt | | base_protocol | false | boolean | | name | opt | | protocol_name | "file" | string | | of | of | instances | | Water Contract<class resource.filesystem.file
/> | |
See also: folder, create, set, insert, append, set_file_content_and_create_folders_as_needed, vector, remove
Creates a file resource from a path.
a wob
| Parameter key | Default value | Type |
| a_uri | opt |
This field specifies the path to the desired file resource.
Example: Create a file object
<file "file:///C:/Documents and Settings/mstemen/My Documents/test_file.txt" />
Example: Using Water's logical specifier
<file "logical://user/test_file.txt" />
The examples above only create a file reference object. To actually
create the file on the filesystem, a couple of methods may be
employed.
Creating a file
The create method may be employed to create a file on the
filesystem.
Example: Creating an empty file
<file "logical://user/new_test_file.txt" />.<create />
This method returns the newly created file object.
Files can also be created very simply in Water by using the set
method of the file object to set the content of the
file.
Example: Creating a file by setting its content
<file "logical://user/new_test_file.txt" />.<set content="new stuff" />
This method returns the newly created file object.
Adding content to a file
Water provides several other methods for manipulating content of
data files. See the specific documentation for the various methods
the file class has available for more information about
manipulating file content.
Retrieving content from a file
The content field retrieves the content of a file.
Example: Retrieving content from a file
<file "logical://user/some_file.txt" />.content
 | "the content of the file" |
Once the content is retrieved, the data may be manipulated in various
ways, and then the file may be rewritten using the set method.
© Copyright 2007 Clear Methods, Inc.