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>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 that controls read-only or
    read/write access for the file specified by 'pathname'.  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.

 Portability:   Not supported by ANSI standard.

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

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

           #include <sys\types.h>l
           #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