Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_dos_getfileattr() get file or directory attributes</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _dos_getfileattr()      Get file or directory attributes

 #include   <dos.h>

  unsigned     _dos_getfileattr(path, attribute);
  char *path;  File name and path
  unsigned *attribute;   Location of returned attributes

    _dos_getfileattr() uses MS-DOS function 43h to get the attributes of
    the file or directory specified by 'path'. The attribute values are
    returned in the low-order byte of 'attribute', represented by the
    following manifest constants:

                    Constant     Meaning
                    ------------------------------------------------
                    _A_NORMAL    Normal file, can be read and written to.
                    _A_RDONLY    Read only file
                    _A_HIDDEN    Hidden file
                    _A_SYSTEM    System file
                    _A_VOLID     Volume ID
                    _A_SUBDIR    Subdirectory
                    _A_ARCH      Archive, file changed since last backup

    Returns:    _dos_getfileattr() returns 0 if successful. If
                unsuccessful it returns the MS-DOS error code and sets
                errno to ENOENT indicating the file or directory could
                not be found.

   Portability:     MS-DOS only, version 2.0 or higher

------------------------------- Example ---------------------------------

 This program gets and reports the attributes of the file "test.c"

           #include <dos.h>

           main()
           {
              unsigned attribute;
              unsigned return_val;

              return_val = _dos_getfileattr( "test.c", &attribute );
              if (return_val)
                 printf("File \"test.c\" not found\n");
              else
                 {
                 printf("These are the attributes of \"test.c\":\n");
                 if (attribute == _A_NORMAL)    /* 00h -- no bits set */
                    printf("\tNormal file, backed up since last edit");
                 else
                    {
                    if ((attribute & _A_RDONLY) != 0)
                       printf("\tRead only file\n");
                    if ((attribute & _A_HIDDEN) != 0)
                       printf("\tHidden file\n");
                    if ((attribute & _A_ARCH) != 0)
                       printf("\tNot backed up since last edit\n");
                    }
                 }
           }


See Also: _dos_setfileattr()

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