From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.129.88.70 with SMTP id m67mr9159307ywb.26.1440791362566; Fri, 28 Aug 2015 12:49:22 -0700 (PDT) X-Received: by 10.182.52.132 with SMTP id t4mr63876obo.25.1440791362534; Fri, 28 Aug 2015 12:49:22 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!62no87839qgj.1!news-out.google.com!f6ni8078igi.0!nntp.google.com!u8no181851igq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 28 Aug 2015 12:49:22 -0700 (PDT) In-Reply-To: <75714e3f-c047-413d-9aa5-3ff423167863@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=24.6.21.101; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 24.6.21.101 References: <75714e3f-c047-413d-9aa5-3ff423167863@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Exclusive file access From: Anh Vo Injection-Date: Fri, 28 Aug 2015 19:49:22 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:27631 Date: 2015-08-28T12:49:22-07:00 List-Id: On Friday, August 28, 2015 at 10:40:47 AM UTC-7, ah...@marriott.org wrote: > Our working solution was to use the Windows API to open the file and then use Windows API calls to read and write to it. > We did this because using OA there wasn't a way to open files with non-ascii file names. > However it meant that we had to write our own filing system. > > 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. > The hope was that it would also be platform independent. > From what everyone has written it seems that this is not possible. > It seems that I should somehow lock the file once it has been opened by Ada. > Has anyone any suggestions how best to do that? > Ie How does one write a GNAT Ada program for windows that has exclusive access when opened for write. Surely this must be a common requirement? I would suggest to wrap it in a protected object. It checks for task id of a process opening and reading must be the same. Otherwise, the unidentified task will be blocked from accessing the file. Anh Vo