FILINFO

Contents


filinfo is used to find all the properties of a "physical" file given in the argument. The supplementary argument specifies the property to be found.

 

Syntax

   filinfo( path_fil, arg_ent )

 

Parameters

 

Element

Description

Restrictions

path_fil

Char type expression for the file path to be tested.

None

arg_ent

Integer expression specifying the property to be found

0 <= arg_ent <= 10

 

Examples

   # To find the size of a file in number of octets.
   # If the filesize found is negative, the file does not exist.
    TAILLE_FIC = filinfo(FICHIER, 7)
   # What is the type of the Unix file FICHIER?
   # the values P1, P2, PDIR, PCAR, PBLO, PFI1, PFI2, PFIF
   # may be dependent on the Unix version
   # (Check in the mknod (2) documentation).
    P1 = 2 ^ 12 : P2 = 16
    PFIF = 1 : PCAR = 2 : PDIR = 4 : PBLO = 6 : PFI1 = 0 : PFI2 = 8
   #
   # Read file mode: if negative, there is an access error
    MODE_FIC = filinfo(FICHIER, 0)
    If MODE_FIC < 0 : Errbox "Error on file :"-errmes$(-MODE_FIC)
       Return
    Endif
   # Otherwise, test the 'file type' part of the mode
    Case int(mod(MODE_FIC/P1, P2))
       When PFIF : Erbox FICHIER-": fifo"
       When PCAR : Errbox FICHIER-": character mode peripheral"
       When PDIR : Errbox FICHIER-" : directory"
       When PBLO : Errbox FICHIER-": block mode peripheral"
       When PFI1, PFI2
                   Errbox FICHIER-": file normal"
       When default :
                   Errbox FICHIER-": mode unknown"
    Endcase
   # There are two files xx.c and xx.o in the current directory.
   # If file xx.c is more recent than xx.o, recompilation is required
   #
    Char TRACE_ERR(80)(1..24)
   # Check date of latest modification
    If filinfo("xx.c", 9) > filinfo("xx.o", 9)
        Infbox "Recompilation in progress...."
        System "cc -c xx.c -o xx.o 2>trace.com"
        Infbox "Compilation complete"
       # Is the trace file empty?
        If filinfo("trace.com", 7)
            Infbox "Here is the error record..."
       System TRACE_ERR = "cat trace.com"
            For I = 1 to min(stat1, dim(TRACE_ERR))
                   Infbox TRACE_ERR(I)
            Next I
        Endif
    Endif
   # A file is to be modified if its number of links is 1
    NB_LIENS = filinfo(REPERTOIRE+"/"+FICHIER,4)
    If NB_LIENS<0    : Errbox "File does not exist !"
    Elsif NB_LIENS >1: Errbox "Warning, the file is linked elsewhere"
    Else
       Openio REPERTOIRE+"/"+FICHIER
       ...
    Endif

 

Description and comments

The function filinfo is used to find all the properties of a physical file (not a table) whose pathname is given in the argument. A second argument also gives the property required. The match between the second argument and the property is given in the following table:

argt.

file property

WIN95

N.T.

Unix

0
1
2

3

4
5
6
7
8

9
10

Filemode (type, permissions)
Number of inode corresponding to the file.
ID of peripheral containing an entry
on this file.
ID of peripheral (if the file is
a peripheral in character or block mode)
Number of links.
User number of the owner of the file.
Number of the group owner of the file.
Size of file in octets.
Last date of access (in seconds
since 01/01/1970 0:0:0:GMT).
Last date of modification (ditto)
Last change of status (ditto)

Yes
No
No

No

1
No
No
Yes
Yes

*

Yes
No
No

No

1
Yes
Yes
Yes
Yes

*
*

Yes
Yes
Yes

Yes

Yes
Yes
Yes
Yes
Yes

Yes
Yes

* under Windows 95, the result is the same for parameters 8, 9, and 10 for the last access date (8).

Note: the response is 0 when the operating system does not return anything.

 

Comments

The result returned is an Integer type.

Under Windows, the path may be written either with "/" or with "\".

If the file does not exist, or is inaccessible, the function filinfo returns the corresponding error number (with a negative sign) without generating an error in the routine. In principle, errors returned will be in the following list:

Error

Description

PAFIC         (20)

The file does not exist.

ERACCE    (27)

access error (that is, directory in principle inaccessible)

 

Associated errors

Error

Description

ERMODE(10)

The first argument is not a Char type
The 2nd argument is not an Integer type

ERDOM      (50)

The 2nd argument is not in the range [0, 10].

 

Associated key words

FILPATH - FILCOM  -  OPENI  -  OPENO  -  OPENIO


CONTENTS


Copyright © Sage 1999 - 2007