use chmod() in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • datct0407
    New Member
    • Sep 2008
    • 3

    use chmod() in C

    I want to use function chmod() to remove all attribution of a file in C, but i don't know how!
    Can you help me!
  • boxfish
    Recognized Expert Contributor
    • Mar 2008
    • 469

    #2
    I don't know if this is what you're looking for, but you can use the system() function to have a C program execute a command.

    Comment

    • datct0407
      New Member
      • Sep 2008
      • 3

      #3
      for example, I have a file as SYSTEM.INI, its attributions are HIDDEN, ARCHIVE, READ ONLY. And I want to remove all attribution it has.
      Do you understand??? Help me!

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by datct0407
        for example, I have a file as SYSTEM.INI, its attributions are HIDDEN, ARCHIVE, READ ONLY. And I want to remove all attribution it has.
        Do you understand??? Help me!
        In most (if not all) unices there's the chmod(2) function:

        Code:
        #include <sys/types.h>
        #include <sys/stat.h> 
        int chmod(const char *path, mode_t mode);
        For windows I vaguely remember a 'cacls' method; check it out.

        kind regards,

        Jos

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          Originally posted by JosAH
          For windows I vaguely remember a 'cacls' method; check it out.
          Yes or you could use SetFileAttribut es. You would be well advised to call GetFileAttribut es first though and only change what you want.

          Comment

          • datct0407
            New Member
            • Sep 2008
            • 3

            #6
            maybe You don't understand my question!
            I want to remove all attributions, not set attributions!
            ok??

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              Originally posted by datct0407
              maybe You don't understand my question!
              I want to remove all attributions, not set attributions!
              ok??
              May be you have failed to RTFM

              Comment

              Working...