469,638 Members | 1,574 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,638 developers. It's quick & easy.

is chmod(766) possible in C++?

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
Sep 19 '05 #1
5 9287

"Stewart" <rs********@blueyonder.co.uk> wrote in message
news:ef***************@fe1.news.blueyonder.co.uk.. .
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
Sep 19 '05 #2
Howard wrote:
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
--

Sep 19 '05 #3
Stewart wrote:
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
Sep 20 '05 #4
Wolfgang Draxinger wrote:
Howard wrote:

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:


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
Sep 20 '05 #5
Ah, right. thanks for your help.
Sep 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.