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 Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <sys\types.h>
    #include <sys\stat.h>
    #include <io.h>
    int chmod( const char *path, int permission );
    int _wchmod( const wchar_t *path, int permission );

Description:
    The chmod function changes the permissions for a file specified by path
    to be the settings in the mode given by permission.  The access
    permissions for the file or directory are specified as a combination of
    bits (defined in the <sys\stat.h> header file).

    The following bits define permissions for the owner.

    Permission     Meaning

S_IRWXU
    Read, write, execute/search

S_IRUSR
    Read permission

S_IWUSR
    Write permission

S_IXUSR
    Execute/search permission

    The following bits define permissions for the group.

    Permission     Meaning

S_IRWXG
    Read, write, execute/search

S_IRGRP
    Read permission

S_IWGRP
    Write permission

S_IXGRP
    Execute/search permission

    The following bits define permissions for others.

    Permission     Meaning

S_IRWXO
    Read, write, execute/search

S_IROTH
    Read permission

S_IWOTH
    Write permission

S_IXOTH
    Execute/search permission

    The following bits define miscellaneous permissions used by other
    implementations.

    Permission     Meaning

S_IREAD
    is equivalent to S_IRUSR (read permission)

S_IWRITE
    is equivalent to S_IWUSR (write permission)

S_IEXEC
    is equivalent to S_IXUSR (execute/search permission)

    Upon successful completion, the chmod function will mark for update the
    st_ctime field of the file.

    The _wchmod function is identical to chmod except that it accepts a
    wide-character string argument.

Returns:
    The chmod returns zero if the new settings are successfully made;
    otherwise, -1 is returned and  errno is set to indicate the error.

Errors:
    When an error has occurred,  errno contains a value indicating the type
    of error that has been detected.

    Constant     Meaning

EACCES
    Search permission is denied for a component of path.

ENOENT
    The specified path does not exist or path is an empty string.


Example:
    /*
     * change the permissions of a list of files
     * to be read/write by the owner only
     */

    #include <stdio.h>
    #include <stdlib.h>
    #include <sys\types.h>
    #include <sys\stat.h>
    #include <io.h>

    void main( int argc, char *argv[] )
      {
        int i;
        int ecode = 0;

        for( i = 1; i < argc; i++ ) {
          if( chmod( argv[i], S_IRUSR | S_IWUSR ) == -1 ) {
            perror( argv[i] );
            ecode++;
          }
        }
        exit( ecode );
      }

Classification:
    chmod is POSIX 1003.1, _wchmod is not POSIX

Systems:
     chmod - All, Netware

    _wchmod - DOS, Windows, Win386, Win32, OS/2 1.x(all), OS/2-32

See Also:
    fstat, open, sopen, stat

See Also:

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