By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,569 Members | 1,350 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,569 IT Pros & Developers. It's quick & easy.

is chmod(766) possible in C++?

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
Ah, right. thanks for your help.
Sep 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.