$fileproperties

Return the properties of the specified file, directory, or zip archive, taking file redirections in the assignment file into account.

$fileproperties(FilePath | DirPath {, Topic})

Example: if ($fileproperties(vFile,"Filetype") = "FILETYPE=FILE") ...

Parameters

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

$fileproperties 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.
Properties that can be returned by $fileproperties and $lfileproperties
Topic Returned value Normal Files Zip Files
FILETYPE On MS Windows, Unix —DIR or FILE

On iSeries—DIR if it is an IFS directory (DIR or DDIR); FILE if the object is an IFS stream file (STMF or DSTMF) or a file in a library (*FILE); for other object types, the type returned by the OS, without the '*,' for example MBR, LIB, PGM, SRVPGM, USRSPC etc.

ü ü
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 ZIPFILENAME.

ü ü
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.

  • MS Windows—zero or more of the letters RHSACET, where R=read-only, H=hidden, S=system, A=archive, C=compressed, E=encypted.

    For files located in zip archives— T=text file or ""=other (binary) files

  • UNIX—string is rw[x | s] rw[x | s] rwx. Granted permissions are represented by the respective letter in the string:

    r=read; w=write; x=execute; s=execute plus set user/group ID permission. This format resembles the format of ls -l.

    Absence of a permission is represented by a dash (-).

  • iSeries—string is rw[x|s]rw[x|s]rwx.

    It is equivalent to what the QSH command ls -lFile produces. If the file is an object in the library system, it is followed by a comma and RAUDE,OMEAR.

    This additional string refers to the permissions for the object of the current process only; group or public authorities are not included (unlike the Unix-like part, which represents user, group and world privileges).

    RAUDE represents the data permissions: R: read; A: add; U: update; D: delete; E: execute

    OMEAR represents the object permissions: O: operation; M: management; E: existence; A: alter; R: reference.

    Absence of a particular privilege is represented by a dash -.

    For more information, refer to the iSeries documentation, such as the documentation of EDTOBJAUT.

ü ü
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:
  • 0—file or object is stored without compression
  • 8—file or object is stored and compressed in a zip archive
  ü
ZIPFILENAME Full path to the zip archive that contains the file or directory. When using relative paths, the path includes the working directory.   ü
Values commonly returned by $procerror following $fileproperties and $lfileproperties
Value  Error constant Meaning
-13 <UIOSERR_OS_COMMAND>

An error occurred while trying to perform the OS command. Set /pri=64 to display the exact error in the message frame.

-1110 <UPROCERR_TOPIC> Topic name not known.
-1132 <UPROCERR_UNRESOLVED_TOPIC> Topic could not be resolved.

Use

Allowed in all Uniface component types.

Description

The $fileproperties function returns an associative list of the properties of the specified file or directory, taking file redirections in the assignment file into account. 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 example ab?, or in its suffix, for example abc\*.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:

vFile = "sub1dir\test.txt"
if ($fileproperties(vFile,"Filetype") = "FILETYPE=FILE")
 fileload vFile, vContent
endif

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 = $fileproperties("..\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"

Related Topics