Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - fileattrib() return attributes of the specified file http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fileattrib()        Return attributes of the specified file
------------------------------------------------------------------------------
 Declaration
   file.hdr

 Syntax
   func uint fileattrib extern
   param const char cFileName

 Arguments
   cFileName is the name of the file to retrieve information about.

 Return
   An integer representing the file attributes, or 0 if the file does not
   exist, or a subdirectory or volume label name is passed.

 Description
   The fileattrib() function returns the attribute of the specified disk
   file, cFileName.

   The file attributes are represented by bits in the return value:

   bit 7 6 5 4 3 2 1 0
      +---------------+
      | | |a|-|-|s|h|r|
      +---------------+
           |     | | |
           |     | | +-- read only  (1)
           |     | +---- hidden     (2)
           |     +------ system     (4)
           +------------ archive   (32)

   If a file has more than one attribute set, the sum of the attribute values
   will be returned.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   vardef static
      char( 3 ) cYes := "yes"
      char( 2 ) cNo  := "no"
   enddef
   
   proc ShowAttributes
   param const char cFile
   vardef
      uint uAttr
   enddef
   uAttr := FileAttrib( cFile )
   ? "File      " + cFile
   ? "Attribute " + istr( uAttr )
   ? "Read only " + iifc( testbit( uAttr, FINDBIT_READONLY  ), cYes, cNo )
   ? "Hidden    " + iifc( testbit( uAttr, FINDBIT_HIDDEN    ), cYes, cNo )
   ? "System    " + iifc( testbit( uAttr, FINDBIT_SYSTEM    ), cYes, cNo )
   ? "Archive   " + iifc( testbit( uAttr, FINDBIT_ARCHIVE   ), cYes, cNo )
   ? "Shareable " + iifc( testbit( uAttr, FINDBIT_SHAREABLE ), cYes, cNo )
   endproc
   
   proc Test_fileattrib
   if .not. isempty( argv( 1 ) )
      ShowAttributes( argv( 1 ) )
   else
      ? "Supply a file name"
   endif
   endproc

   proc main
   Test_fileattrib()
   endproc

See Also: chmod() filedate() filesize() filetime() getfiletime()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson