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 - <b>chmod() change file permission setting</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
chmod()                  Change File Permission Setting


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

 int        chmod(pathname, pmode);
 char       *pathname;                   Name of file
 int        pmode;                       Permission setting

    chmod() changes the permission setting of the file specified by
    'pathname'. The permission setting controls whether the file has
    read-only or read and write access. To change the permission setting,
    set the 'pmode' value to:

                S_IWRITE              for write permission
                S_IREAD               for read permission
                S_IREAD | S_IWRITE    for read and write permission

    Returns:    Zero if the permission setting is successfully changed,
                or -1 if there is an error, in which case errno is set to
                ENOENT (file not found).

      Notes:    Under MS-DOS all files are readable; you cannot have a
                write-only file. If write permission is not specified,
                the file is made read-only.

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

    The following statements change the file to read-only status:

           #include <sys\stat.h>
           #include <io.h>

           int result;

           main()
           {
                 result = chmod("invoice.bak", S_IREAD);
                 if (result == -1)
                    perror("can't change permission mode");
            }

See Also: access() creat() fstat() open() stat()

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