comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Exclusive file access
Date: Sat, 29 Aug 2015 09:05:48 +0200
Date: 2015-08-29T09:05:48+02:00	[thread overview]
Message-ID: <nrnswuq80yyi$.uf01xt8a4dz5.dlg@40tude.net> (raw)
In-Reply-To: 75714e3f-c047-413d-9aa5-3ff423167863@googlegroups.com

On Fri, 28 Aug 2015 10:40:45 -0700 (PDT), ahlan@marriott.org wrote:

> Now that we have abandoned OA in favour of Gnat and because Gnat provides
> a mechanism to open files with non-ascii names I had hoped that we could
> abandon all this fancy windows stuff and use plain Ada.

I doubt that. Windows "non-ascii" file names are UTF-16. The only
consistent way to have them would be Wide_Wide_Text_IO with names in
Wide_Wide_String internally recoded to UTF-16. Does GNAT this? I didn't
look at the implementation, but I bet it does not. Then how would you do
I/O if the content is not Wide_Wide_String?

> The hope was that it would also be platform independent.

It is Ada standard which prevents reasonable and portable operations with
Unicode file names. You cannot do anything about that.

(I use GIO instead of Ada.Directories when I have to deal with localized
file names.)

> From what everyone has written it seems that this is not possible.

Not if the language I/O abstraction layer does not have this capability.
Ada's does not.

> It seems that I should somehow lock the file once it has been opened by Ada.

Windows locks the file if the sharing mode is 0. See

https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx

I don't know what flag GNAT ultimately uses, or if it goes through a POSIX
layer, what the later does. Possibly it ends up with FILE_SHARE_READ.

> Has anyone any suggestions how best to do that?

Use Win32Ada.

> Ie How does one write a GNAT Ada program for windows that has exclusive
> access when opened for write.

By using OS API. If you have do deal with many different OSes create an
abstraction layer and have an implementations of per OS.

> Surely this must be a common requirement?

It is not. Concurrently accessed files presume some persistency being
implemented. It is very uncommon to be done at the file level. DBMS are for
this. When single-file persistency is used it is most of the time an
embedded target where you need not to care about concurrent access.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  parent reply	other threads:[~2015-08-29  7:05 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-27 13:52 Exclusive file access ahlan
2015-08-27 14:27 ` gautier_niouzes
2015-08-31 23:20   ` Randy Brukardt
2015-09-01 16:23     ` Pascal Obry
2015-09-01 20:48       ` Randy Brukardt
2015-08-27 14:42 ` Björn Lundin
2015-08-27 14:48 ` G.B.
2015-08-27 15:08   ` Björn Lundin
2015-08-27 18:38     ` tmoran
2015-08-27 23:16     ` Georg Bauhaus
2015-08-27 23:29       ` Pascal Obry
2015-08-28  7:25         ` Georg Bauhaus
2015-08-27 15:15   ` ahlan
2015-08-27 18:29     ` Jeffrey R. Carter
2015-08-28  5:41 ` ahlan
2015-08-28  7:10   ` Georg Bauhaus
2015-08-28 17:40 ` ahlan
2015-08-28 19:49   ` Anh Vo
2015-08-28 21:06     ` Simon Wright
2015-08-28 21:38       ` Jeffrey R. Carter
2015-08-29  7:05   ` Dmitry A. Kazakov [this message]
2015-08-29  8:31     ` Pascal Obry
2015-08-29 12:02       ` Dmitry A. Kazakov
2015-08-30 11:35         ` Florian Weimer
2015-08-30 12:44           ` Dmitry A. Kazakov
2015-08-30 19:37             ` Florian Weimer
2015-08-31  7:22               ` Dmitry A. Kazakov
2015-08-31 21:12                 ` Florian Weimer
2015-09-01  7:26                   ` Dmitry A. Kazakov
2015-09-07 18:27                     ` Florian Weimer
2015-09-07 19:06                       ` Dmitry A. Kazakov
2015-09-11 16:54                         ` Florian Weimer
2015-08-31 23:34             ` Randy Brukardt
2015-09-01  7:33               ` Dmitry A. Kazakov
2015-08-29 16:07     ` gautier_niouzes
2015-08-29 17:12       ` Dmitry A. Kazakov
2015-09-01 12:37 ` brbarkstrom
2015-09-01 14:05 ` ahlan
2015-09-01 15:13   ` Simon Wright
2015-09-01 20:36     ` Randy Brukardt
2015-09-01 15:17   ` Jacob Sparre Andersen
2015-09-01 20:37     ` Randy Brukardt
2015-09-01 16:05   ` G.B.
2015-09-01 20:02   ` brbarkstrom
2015-09-01 21:17     ` Simon Wright
2015-09-05 15:52       ` Björn Lundin
2015-09-01 20:31   ` Randy Brukardt
2015-09-01 15:31 ` ahlan
2015-09-05 15:56   ` Björn Lundin
2015-09-06 17:38     ` brbarkstrom
2015-09-06 19:52       ` Björn Lundin
2015-09-07 15:18         ` brbarkstrom
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox