stdc++ fstream file permission

A

Avner

I have a C++ code which I want to upgrade to the standard C++

The code constructs a file and sets the file permission
The new iostream library does not include filebuf::eek:penprot

The old ofstream constructor (<fstream.h>) accepts a third parameter (int
nProt = filebuf::eek:penprot)

i.e. ofstream( const char* szName, int nMode = ios::eek:ut, int nProt =
filebuf::eek:penprot );

but the standard ofstream constructor (<fstream>) does not accept the third
parameter anymore.


How do I preserve the functionality to set the file permission?

Thanks,
Avner
 
L

Larry I Smith

Avner said:
I have a C++ code which I want to upgrade to the standard C++

The code constructs a file and sets the file permission
The new iostream library does not include filebuf::eek:penprot

The old ofstream constructor (<fstream.h>) accepts a third parameter (int
nProt = filebuf::eek:penprot)

i.e. ofstream( const char* szName, int nMode = ios::eek:ut, int nProt =
filebuf::eek:penprot );

but the standard ofstream constructor (<fstream>) does not accept the third
parameter anymore.


How do I preserve the functionality to set the file permission?

Thanks,
Avner

As Victor replied to your earlier post - you can't (using the Std Lib).

You can use the POSIX open()/close() functions (available on all POSIX
compliant systems, Windows, unix, etc). To create the file with the
desired permissions, then use an ofstream to put data in the file.

Larry
 

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
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top