Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <dos.h>
    unsigned _dos_setfileattr( char *path,
                               unsigned attributes );

Description:
    The _dos_setfileattr function uses system call 0x43 to set the
    attributes of the file or directory that path points to.  The possible
    attributes are:

    _A_NORMAL
        Indicates a normal file.  File can be read or written without any
        restrictions.

    _A_RDONLY
        Indicates a read-only file.  File cannot be opened for "write".

    _A_HIDDEN
        Indicates a hidden file.  This file will not show up in a normal
        directory search.

    _A_SYSTEM
        Indicates a system file.  This file will not show up in a normal
        directory search.

    _A_VOLID
        Indicates a volume-ID.

    _A_SUBDIR
        Indicates a sub-directory.

    _A_ARCH
        This is the archive flag.  It is set whenever the file is modified,
        and is cleared by the MS-DOS BACKUP command and other backup utility
        programs.


Returns:
    The _dos_setfileattr function returns zero if successful.  Otherwise, it
    returns an MS-DOS error code and sets  errno to one of the following:

    ENOENT
        No file or directory matched the specified path.

    EACCES
        Access denied; cannot change the volume ID or the subdirectory.


See Also:
    _dos_getfileattr

Example:
    #include <stdio.h>
    #include <dos.h>

    print_attribute()
      {
        unsigned attribute;

        _dos_getfileattr( "file", &attribute );
        printf( "File attribute is %x\n", attribute );
        if( attribute & _A_RDONLY ) {
            printf( "This is a read-only file\n" );
        } else {
            printf( "This is not a read-only file\n" );
        }
      }

    void main()
      {
        int      handle;

        if( _dos_creat( "file", _A_RDONLY, &handle ) != 0 ){
          printf( "Error creating file\n" );
        }
        print_attribute();
        _dos_setfileattr( "file", _A_NORMAL );
        print_attribute();
        _dos_close( handle );
      }

Classification:
    DOS

Systems:
    DOS, Win, OS/2 1.x(all), OS/2 2.x, NT, DOS/PM

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