is chmod(766) possible in C++?

S

Stewart

Hi, I'm working on a program in VC++ right now that needs to set file
permissions of a given file to 766 (read/write/execute). Now I've found
the _chmod() function in the API help docs, but that only caters for
read/write.

Is there ANY way of setting 766 to a file through C++ at all?

Many thanks.

Mike
 
H

Howard

Stewart said:
Hi, I'm working on a program in VC++ right now that needs to set file
permissions of a given file to 766 (read/write/execute). Now I've found
the _chmod() function in the API help docs, but that only caters for
read/write.

Is there ANY way of setting 766 to a file through C++ at all?

You need to ask this in a vc++ or win32 newsgroup.

-Howard
 
W

Wolfgang Draxinger

Howard said:
You need to ask this in a vc++ or win32 newsgroup.

You mean POSIX. Windows doesn't know numerical permissions, like
Unix.

@ the OP: It seems like you're developing in a *nix environment:

$ apropos chmod
chmod (1) - change access permissions of files
chmod (2) - change permissions of a file
fchmod [chmod] (2) - change permissions of a file

So, how about
$ man 2 fchmod

(...)

int fchmod(int fildes, mode_t mode);

(...)

Wolfgang Draxinger
--
 
L

Larry I Smith

Stewart said:
Hi, I'm working on a program in VC++ right now that needs to set file
permissions of a given file to 766 (read/write/execute). Now I've found
the _chmod() function in the API help docs, but that only caters for
read/write.

Is there ANY way of setting 766 to a file through C++ at all?

Many thanks.

Mike

VC++ and associated libs are MS Windows specific.

MS Windows does NOT support the 'execute' bit in _chmod()
because MS Windows determines whether or not a file
is executable based solely on the last extension of the
filename, e.g.

'stuff' is not executable
'stuff.exe' is executable
'stuff.bat' is executable
'stuff.cmd' is executable

Larry
 
J

John Harrison

Wolfgang said:
Howard wrote:




You mean POSIX. Windows doesn't know numerical permissions, like
Unix.

@ the OP: It seems like you're developing in a *nix environment:

No, the leading underscore gives it away. This is a Windows function
partially emulating the well known Unix function.

To the OP, if you want to write Unix style programs in a Windows
environment consider cygwin (www.cygwin.com) otherwise ask in a Windows
newsgroup.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top