467,132 Members | 1,157 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

Opening files in "exclusive mode"?

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
Jul 23 '05 #1
  • viewed: 4559
Share:
2 Replies
Dave Reid wrote:
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

Jul 23 '05 #2
> 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
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by nicholas | last post: by
5 posts views Thread by Savas Ates | last post: by
2 posts views Thread by Tor Inge Rislaa | last post: by
17 posts views Thread by teddysnips@hotmail.com | last post: by
10 posts views Thread by albert.neu@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.