Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6372

Re: C++ File Lokcing

From Victor Bazarov <v.bazarov@comcast.invalid>
Newsgroups comp.lang.c++
Subject Re: C++ File Lokcing
Date 2011-06-07 15:16 -0400
Organization A noiseless patient Spider
Message-ID <isltf1$gh2$1@dont-email.me> (permalink)
References (3 earlier) <islhj4$ajo$1@reader1.panix.com> <islhlo$u5n$1@dont-email.me> <islpuv$rhi$1@reader1.panix.com> <islqai$qij$1@dont-email.me> <islrua$rhi$4@reader1.panix.com>

Show all headers | View raw


On 6/7/2011 2:50 PM, Ruben Safir wrote:
>
>> But Ruben, there is no such thing in C++ as "file descriptor".  POSIX
>> and C++ are orthogonal, not part of each other.  On some systems there
>> *may* be a way to get something from 'std::ios_base' other than what the
>> Standard specifies, but it's *not* specified by the Standard, and that's
>> why you need to *ask elsewhere*.  Can you not see that?
>>
>> V
>
> Reading that other newsgroup for over a decade, I can tell you that
> nobody there has the expertise in C++ to event shine your toe nail.
>
> Talking to friends at Google, evidently they don't use ios base for file
> access.  They use unistd.h, fcntl.h, sys/file.h,
>
> something is wrong,  I'm not trolling, but it is fustrating me and
> puzzles me too spend a month learning the details of a rather exotic
> iostream class in C++ and then to find that it is all but useless because
> you can't lock the files,

You *have* to use the means offered by the OS for file locking, there is 
no choice in that.  The Standard C++ Library simply *has no such means*.

There are some choices available, as I see it.  *If* there is a way to 
lock the file at the OS level by the file *name*, you can open it using 
C++ mechanism *after* it's been locked.  The other way is to use *the OS 
means* to do all file-related manipulations, including I/O (reading and 
writing), *if* locking is only possible during/after opening.  The 
former way would allow easy use of 'ofstream' (if you so desire).  The 
latter way would force you to use reading/writing using POSIX (not that 
bad), but you *could* lose the desired functionality of 'ostream'.

Since there is no file locking in C++ (as it's defined in its Standard), 
you sill need to ask elsewhere (regardless of their C++ abilities). 
Having learned how to lock files in your OS, try writing your program in 
C++ and if you experience problems (C++ problems, not OS problems), come 
back and ask about them.

There are other places where you should consider asking.  There is the 
compiler newsgroup, gnu.g++.help (if you're using G++), for instance.

Programming a specific OS will need to be learned, and you're capable of 
learning it, I am sure.  Unfortunately, *this newsgroup* is *not* the 
place to do that.

Good luck!

V
-- 
I do not respond to top-posted replies, please don't ask

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

C++ File Lokcing ruben safir <ruben@mrbrklyn.com> - 2011-06-06 22:41 +0000
  Re: C++ File Lokcing "osmium" <r124c4u102@comcast.net> - 2011-06-06 19:25 -0500
    Re: C++ File Lokcing Juha Nieminen <nospam@thanks.invalid> - 2011-06-07 06:25 +0000
    Re: C++ File Lokcing Öö Tiib <ootiib@hot.ee> - 2011-06-07 00:32 -0700
    Re: C++ File Lokcing ruben safir <ruben@mrbrklyn.com> - 2011-06-07 11:54 -0400
      Re: C++ File Lokcing Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-07 11:55 -0400
        Re: C++ File Lokcing Ruben Safir <ruben@mrbrklyn.com> - 2011-06-07 18:17 +0000
          Re: C++ File Lokcing Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-07 14:23 -0400
            Re: C++ File Lokcing Ruben Safir <ruben@mrbrklyn.com> - 2011-06-07 18:50 +0000
              Re: C++ File Lokcing Victor Bazarov <v.bazarov@comcast.invalid> - 2011-06-07 15:16 -0400
              Re: C++ File Lokcing Jeff Flinn <TriumphSprint2000@hotmail.com> - 2011-06-07 15:47 -0400
              Re: C++ File Lokcing Paavo Helde <myfirstname@osa.pri.ee> - 2011-06-07 15:04 -0500
                Re: C++ File Lokcing Ruben Safir <ruben@mrbrklyn.com> - 2011-06-07 22:46 +0000
                Re: C++ File Lokcing Nobody <nobody@nowhere.com> - 2011-06-08 07:50 +0100
                Re: C++ File Lokcing Sherm Pendley <sherm.pendley@gmail.com> - 2011-06-08 20:55 -0400
                Re: C++ File Lokcing Öö Tiib <ootiib@hot.ee> - 2011-06-08 18:33 -0700
              Re: C++ File Lokcing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-08 07:43 +0000
            Re: C++ File Lokcing Nobody <nobody@nowhere.com> - 2011-06-07 21:21 +0100
          Re: C++ File Lokcing Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-06-08 07:21 +0000
          Re: C++ File Lokcing Paavo Helde <myfirstname@osa.pri.ee> - 2011-06-08 16:14 -0500
            Re: C++ File Lokcing drew@furrfu.invalid (Drew Lawson) - 2011-06-08 22:19 +0000
            Re: C++ File Lokcing Nobody <nobody@nowhere.com> - 2011-06-09 02:54 +0100

csiph-web