xHarbour Reference Documentation > Function Reference |
Returns the attributes of a file.
FileAttr( [<cFileName>] ) --> nAttributes
The function returns the attributes of a file as a numeric value, or -1 on error. See the example for decoding the return value.
See also: | FileDate(), FileSeek(), FileSize(), FileTime(), SetFAttr() |
Category: | CT:DiskUtil , File functions , Low level file functions |
Source: | ct\files.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example lists #define constants that can be used for // decoding the return value of FileAttr() #define FA_NORMAL 0 #define FA_RDONLY 1 /* R */ #define FA_HIDDEN 2 /* H */ #define FA_SYSTEM 4 /* S */ #define FA_LABEL 8 /* V */ #define FA_DIREC 16 /* D */ #define FA_ARCH 32 /* A */ #define FA_DEVICE 64 /* I */ #define FA_TEMPORARY 256 /* T */ #define FA_SPARSE 512 /* P */ #define FA_REPARSE 1024 /* L */ #define FA_COMPRESSED 2048 /* C */ #define FA_OFFLINE 4096 /* O */ #define FA_NOTINDEXED 8192 /* X */ #define FA_ENCRYPTED 16384 /* E */ #define FA_VOLCOMP 32768 /* M */ PROCEDURE Main LOCAL aFiles := Directory( "\xhb\lib\*.*" ) LOCAL aFile FOR EACH aFile IN aFiles ShowAttr( "\xhb\lib\" + aFile[1] ) NEXT RETURN PROCEDURE ShowAttr( cFile ) LOCAL nAttr := FileAttr( cFile ) IF ( nAttr == -1 ) ? "File not found ", cFile RETURN ENDIF ? "Attrib: " IF ( nAttr & FA_RDONLY ) > 0 ?? "Readonly " ENDIF IF ( nAttr & FA_HIDDEN ) > 0 ?? "Hidden " ENDIF IF ( nAttr & FA_SYSTEM ) > 0 ?? "System " ENDIF IF ( nAttr & FA_DIREC ) > 0 ?? "Directory " ENDIF IF ( nAttr & FA_ARCH ) > 0 ?? "Archive " ENDIF IF ( nAttr & FA_NORMAL ) > 0 ?? "Normal " ENDIF IF ( nAttr & FA_TEMPORARY ) > 0 ?? "Temp " ENDIF RETURN
http://www.xHarbour.com