GetStat

Demonstrates how to get detailed information of a file.

Remarks

This example fetches a list of the files in a directory and prints them out with a special indication for files that are directories.

The information returned is formatted in a string constant with information located in formatted fields. If the file does not exist or some other error occurs, a blank string will be returned. The string fields are organized as follows:

 Type 1-1: The type of the file.  One of F (file), D (directory), 
           V (device), or O (other).

 Size 2-12: File size in bytes, right justified.

Other information is also appended about mode and access times, but this is not documented as it may be changed in the future.

Code

 local mstring listing
 local int i
 local string stat
 local string rootpath

 rootpath = GetPCIHOME()
 listing = GetDirectory( rootpath )

 print f$len(listing)

 for i = 1 to f$len(listing)
   
   stat = GetStat( rootpath + listing[i] )

   if( stat(1) = "D" )then
     print listing[i] + " (dir) ",  " " , stat, " ", f$len(stat)
   else
     print listing[i], " ", stat, " ", f$len(stat)
   endif
 endfor

Output

8
BuildTimes.txt F          0 1044991348 1044991348      33206          2          0        74
changes.srt F          0 1044991354 1044991354      33206          2          0        74
changes.txt F          0 1044991354 1044991354      33206          2          0        74
cuprite.hdf F          0 1044991354 1044991354      33206          2          0        74
CVS (dir)  D          0 1044991360 1044991360      16895          2          0        74
demo (dir)  D          0 1044991360 1044991360      16895          2          0        74
DevDocs (dir)  D          0 1044991360 1044991360      16895          2          0        74
doc (dir)  D          0 1044991360 1044991360      16895          2          0        74

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.