$lfileproperties
Return the properties of the specified file, directory, or zip archive, ignoring any file redirections in the assignment file.
$lfileproperties(
FilePath | DirPath {,
Topic})
Example: vModDate = $lfileproperties(vFile, "MODIFICATIONDATE")
Parameters
Parameter | Data Type | Description |
---|---|---|
FilePath | String |
File name, optionally preceded by the path to the file. Must not end with a directory separator. |
DirPath | String | Directory name, optionally preceded by the path to the directory. Must end with a directory separator. |
Topic | String | Associative list of attributes, separated
by GOLD ; (; ). If omitted, all the available properties are
returned. |
For more information, see Syntax of File and Directory Names.
Return Values
$lfileproperties returns a list of properties applicable to the file. The properties returned depend on the type of file.
- Associative list of
Topic=Value pairs, separated by GOLD ;
(
;
). - Empty list (
""
) if the file or directory does not exist, or an error occurred. $procerror contains the precise error.
Topic | Returned value | Normal Files | Zip Files |
---|---|---|---|
FILETYPE
|
On MS Windows, Unix —DIR or
FILE On iSeries— |
ü | ü |
FILESIZE
|
Size, in bytes, of the file or object. | ü | ü |
FULLPATH
|
Full path to the file, or the file in a
zip archive. When using relative paths, the path includes the working directory. If the file is in a zip archive, the zip
file and path are specified by |
ü | ü |
CREATIONDATE
|
Date the file was created. String in the
format yyyymmddhhmmsstt , where the ticks (tt ) is always 00. |
ü | ü |
MODIFICATIONDATE
|
Last time the file was modified, in the
same format as CREATIONDATE . Files located in zip archives have the modification date set rather than the creation date. |
ü | ü |
ACCESSDATE
|
Last time the file was accessed, in the
same format as for CREATIONDATE . |
ü | |
FILEATTRIBUTES
|
String containing the file attributes.
|
ü | ü |
COMPRESSEDSIZE
|
Size, in bytes, of the compressed file or object in a zip archive. | ü | |
CHECKSUM
|
32-bit number used to determine whether a file in a zip archive has been modified or corrupted. | ü | |
METHOD
|
Method used to store the file or object;
either:
|
ü | |
ZIPFILENAME
|
Full path to the zip archive that contains the file or directory. When using relative paths, the path includes the working directory. | ü |
Value | Error constant | Meaning |
---|---|---|
-13
|
<UIOSERR_OS_COMMAND>
|
An error occurred while trying to perform
the OS command. Set |
-1110
|
<UPROCERR_TOPIC>
|
Topic name not known. |
-1132
|
<UPROCERR_UNRESOLVED_TOPIC>
|
Topic could not be resolved. |
Use
Allowed in all component types.
Description
The $lfileproperties function returns an associative list of the properties of the specified file or directory, ignoring any file redirections in the assignment file. The file or directory can be located in a zip archive.
Specifying File and Directory Paths
- Each specification can be a string, a field (or indirect reference to a field), a variable, or a function that evaluates to a string.
- The total length of any path (or file name or directory name) must not exceed 255 bytes.
- Valid generic directory separators are the
backward slash (
\
), the forward slash (/
) , and the period (.
) in combination with square brackets ([a.b]
). These are translated to the platform-specific separators. - No wildcards are allowed in any path, except
for $ldirlist and $dirlist, which allows the Uniface
wildcards
?
(GOLD ?) and*
(GOLD *) in the directory name, for exampleab?
, or in its suffix, for exampleabc\*.txt
.
For more information, see Syntax of File and Directory Names.
Checking if a File Exists
The following example checks whether the file test.txt exists in the directory sub1dir and, if so, loads it:
$file$ = "sub1dir\test.txt" ; or $file$ = "sub1dir/test.txt" ; or $file$ = "[.sub1dir]test.txt" if ($lfileproperties($file$,"Filetype") = "FILETYPE=FILE") lfileload $file$, $content$
Extracting a File's Modification Date and Time
This example extracts the modification date and time of the file grid1.xml residing in grid1.zip file of the \mysamples directory. It assumes that the current working directory is d:\usys\project and the return value of the function is:
FILETYPE=FILE ; MODIFICATIONDATE=2006061414351600 ; COMPRESSEDSIZE=24344 ; FILESIZE=272113 ; CHECKSUM=351677385 FULLPATH=GRID1.XML ; METHOD=8 ; FILEATTRIBUTES=T ; ZIPFILENAME=..\mysamples\grid1.zip
FIELD1.MYENTITY = $lfileproperties("..\mysamples\grid1.zip:grid1.xml") ; Extract the modification date: getitem/id $1,FIELD1.MYENTITY,"MODIFICATIONDATE" $2 = $date($1) ; gives $2 = "20060614" ; Extract the modification time: $3 = $clock($1) ; gives $3 = "0000000014351600"
Version | Change |
---|---|
9.1.01 | Added ZIP file support |