comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Operating System differences and Ada OS independent programming
Date: Tue, 22 Mar 2016 09:43:04 +0100
Date: 2016-03-22T09:43:04+01:00	[thread overview]
Message-ID: <ncr0jc$qi6$1@gioia.aioe.org> (raw)
In-Reply-To: ncpr5p$mnb$1@loke.gir.dk

On 21/03/2016 23:04, Randy Brukardt wrote:
> "Dennis Lee Bieber" <wlfraed@ix.netcom.com> wrote in message
> news:dta0fbll6sipc98r88nacm4k9adthj3amn@4ax.com...
> ....
>> Standard library Directories
>> http://www.adaic.org/resources/add_content/standards/05rm/html/RM-A-16.html
>> may provide some help, though it appears to lack a "normalize path"
>> operation... The compose() operation may allow for building up OS
>> compatible paths but is nothing like Python's os.path.join()
>
> There's also Ada.Directories.Hierarchical_File_Names, which adds some of the
> missing parts. (Unfortunately, GNAT missed its addition to Ada 2012, so it
> might not be much help in practice.)
>
> "normalize path" is an attractive idea, but it's pretty much unimplementable
> on Windows. Certain Windows operations will normalize paths, but they don't
> do it consistently. And with the long and short file names on Windows, paths
> *really* need to be normalized. But various Windows documentation says that
> comparing file names should never, ever be done on a Windows system. (It
> turns out that whether two file names are equal depends on the locale
> setting, on the file system of the partition that contains the file, and
> other variables. So it's impossible to compare paths accurately unless you
> know the file system involved -- which makes a general path comparison
> routine impossible [a general routine has to be able to compare paths of
> files that don't necessarily exist, as that might be a preliminary to
> creating a file].
>
> If one follows the advice to avoid comparisons, then there is not much need
> to normalize paths in the first place.

The need is to have portable programs working with directories. 
Comparisons are necessary to have ordered sets of paths. BTW, path 
comparison has nothing to do with the question if both paths denote the 
same file or the same set of files. Under most OS it would be impossible 
to tell normalized path or not. The very notion of "same file" might be 
meaningless under certain circumstances.

Of course, it is not normalization what is needed, but proper typing 
instead. Path is not a string. It must be a defined in the Ada standard 
type with basic operations including OS-dependent string to path 
conversion and backwards. Of course standard packages must take 
instances of the type as parameters when opening a file. This will 
eliminate most if not all real problems (as opposed to imaginary ones) 
with it.

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

  reply	other threads:[~2016-03-22  8:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21 13:18 Operating System differences and Ada OS independent programming ldries46
2016-03-21 15:07 ` gautier_niouzes
2016-03-21 17:24 ` Dennis Lee Bieber
2016-03-21 22:04   ` Randy Brukardt
2016-03-22  8:43     ` Dmitry A. Kazakov [this message]
2016-03-22 11:15       ` G.B.
2016-03-22 13:40         ` Dmitry A. Kazakov
2016-03-22 14:36           ` Stefan.Lucks
2016-03-22 15:08           ` G.B.
2016-03-22 19:06             ` Dmitry A. Kazakov
2016-03-23  8:13         ` gautier_niouzes
2016-03-23  8:38           ` Dmitry A. Kazakov
2016-03-23 15:08             ` G.B.
2016-03-24  8:00               ` Dmitry A. Kazakov
2016-03-24 10:41                 ` G.B.
2016-03-24 10:42                   ` G.B.
2016-03-24 12:16                   ` Dmitry A. Kazakov
2016-03-24  3:36             ` Shark8
2016-03-24  7:58               ` Dmitry A. Kazakov
2016-03-24 11:42                 ` Dennis Lee Bieber
2016-03-24  1:19 ` rieachus
replies disabled

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