Archimaredes
Archimaredes

Reputation: 1427

What was filebuf::openprot intended for, and does it have a replacement?

I'm in the middle of fixing some rather old C++ code that used the old-style iostream library, and I came across the following non-compiling lines of code:

::ofstream ofile;
ofile.open("filename", ios::trunc, filebuf::openprot);

I get this error:

error C2039: 'openprot' : is not a member of 'std::basic_filebuf<_Elem,_Traits>'

So obviously it's something that's not around any more. The problem is, I can't find any information on what openprot did as a parameter, and I therefore can't replace it with something new, and I'm afraid to remove the parameter altogether.

Anyone with any historical C++ knowledge know what this thing did?

Upvotes: 7

Views: 2660

Answers (2)

Anthony
Anthony

Reputation: 12387

That parameter indicates/indicated the protection mode to open the file with. It shows up in this IBM Legacy Class Library Reference.

filebuf::openprot is/was the default argument to the fstream class family constructors and open functions' prot parameter, which indicates what protection mode the file should be opened/created with.

The default protection mode used when opening files.

For example, on your system it might be 0644, meaning that if the file is created, the owner will have read/write permissions, and everyone else will have read-only.

Seeing as in your case the default argument was being passed in anyway, I would say that it's safe to just remove.

Upvotes: 8

Foggzie
Foggzie

Reputation: 9821

According to the Visual Studio 6.0 documentation, openprot uses the operating system's default:

The file protection specification; defaults to the static integer filebuf::openprot, which is equivalent to the operating system default (filebuf::sh_compat for MS-DOS).

Upvotes: 4

Related Questions