Opening files in "exclusive mode"?

D

Dave Reid

Hi everyone...

I'm trying to open a text file in exclusive mode (meaning I want to
lock out any other processes from accessing the file while I'm working with
it).

Here's my code:

ifstream fs_infile("field_summary.dat", filebuf::sh_none)

And I get the following error:

'sh_none' is not a member of type 'filebuf'

What am I doing wrong? Is this the right way to do this? Or is
there a better way to do this file locking?

Thanks in advance...

Dave Reid
 
K

Kristo

Dave said:
Hi everyone...

I'm trying to open a text file in exclusive mode (meaning I want to
lock out any other processes from accessing the file while I'm working with
it).

Here's my code:

ifstream fs_infile("field_summary.dat", filebuf::sh_none)

And I get the following error:

'sh_none' is not a member of type 'filebuf'

What am I doing wrong? Is this the right way to do this? Or is
there a better way to do this file locking?

Thanks in advance...

Your compiler is right. 'sh_none' is not a member of type filebuf.
Opening a file in "exclusive mode" is likely OS-specific. Perhaps you
could ask about it in a newsgroup dedicated to your OS.

Kristo
 
S

Stephen Howe

I'm trying to open a text file in exclusive mode (meaning I want to
lock out any other processes from accessing the file while I'm working
with
it).

No such thing according standard C++.

You want to poke around your compilers documentation and see if they provide
an extension or a means by which you can open in excusive mode.

And/Or post something to your compiler-vendors newsgroups or mailing list.
comp.lang.c++ is no good for this.

Stephen Howe
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top