 |

FILE - Performing file operations with RACE
Note: the "create" action, and "type" property are new as of RACE 3.2 beta and beyond.
-
ACTION - The file action to perform. Available actions are create, delete, copy, move, rename, and get, which determine the additional attributes needed.
-
NAME - The file to perform the desired action on.
-
FROM - When moving, copying, or renaming files, the from attribute indicates the source file.
-
TO - When moving, copying, or renaming files, the to attribute indicates the destination file.
-
PROPERTY - With the action="get" attribute, property indicates the file attribute to retrieve. Available properties are exist (test for existence), type (regular [file], directory or symbolic link), size (in bytes), lastaccess, and lastmodify.
-
FORMAT - When retrieving the lastaccess or lastmodify properties of a file, format defines the date format of the returned value.
The file tag construct is the core of all file manipulation and property retrieval in RACE. For security reasons, the appropriate Apache configuration directives must be defined to access most operations, and RACE allows manipulation of only files under or below the currently executing script's document root.
| Source: |
<file action="get" property="exist" name="index.race"><br>
<file action="get" property="exist" name="i_do_not_exist.race"><br>
<file action="get" property="size" name="index.race"><br>
<file action="get" property="lastaccess" name="index.race" format="HH:mm:ss"><br>
<file action="get" property="lastmodify" name="index.race" format="yyyy-MM-dd HH:mm:ss"><br>
<file action="get" property="type" name="images"><br>
|
| Output: |
true
false
1024
06:08:59
2003-04-06 14:58:23
directory
note:
This example shows all of the "get" properties in action.
|
| Source: |
<file action="delete" name="tempfile.tmp">
|
| Output: |
|
This example will delete a file from the server, returning nothing. If RACE doesn't have proper permissions, <$system.error> will contain information.
|
| Source: |
<define var="$newfile"><date format="HH_mm_ss">.race</define>
<file action="copy" from="<$system.document_current>" to="<$newfile>">
<redirect location="<$newfile>">
|
| Output: |
|
This will copy the currently executing script to a new file, then redirect until Apache's redirect limit is reached. Not recommended, ever.
|
|
 |