Subject: Ada.Directories.Base_Name and dot files
Date: Wed, 07 Oct 2009 14:40:00 +0200
Date: 2009-10-07T14:40:00+02:00 [thread overview]
Message-ID: <4acc8c20$0$284$14726298@news.sunsite.dk> (raw)
Hey all,
While working my way through the excellent Ada.Directories package, I've
stumbled on a minor annoyance: The Base_Name function does not handle
dot files very gracefully.
Here's an example:
++++
with Ada.Text_IO;
with Ada.Directories;
procedure Dot is
package IO renames Ada.Text_IO;
package D renames Ada.Directories;
begin
IO.Put_Line (Item => "1: " & D.Base_Name (Name => "foo.txt"));
IO.Put_Line (Item => "2: " & D.Base_Name (Name => ".foo"));
IO.Put_Line (Item => "3: " & D.Base_Name (Name => ".foo.bar"));
end Dot;
++++
The output I get is this:
++++
1: foo
2:
3: .foo
++++
What I had hoped for, was this:
++++
1: foo
2: .foo
3: .foo
++++
With the current null string solution, you'd have to do some manual
parsing to get to the actual basename of a dot file.
Instead of returning a null string when the first character is a dot,
couldn't Base_Name just as well just return the basename *with* the dot,
because that is the actual basename for a dot file. The dot is part of
the name.
Is there a good reason for the current behavior?
There's a comment in the body of Base_Name:
++++
-- Look for the last dot in the file name and return the part of the
-- file name preceding this last dot. If the first dot is the first
-- character of the file name, the base name is the empty string.
++++
So it's not like the programmers behind this wasn't aware of dot files,
they've just opted for a somewhat odd solution, in my humble, and not
very expert, opinion. :o)
--
Regards,
Thomas L�cke
Email: tl at ada-dk.org
Web: http:ada-dk.org
IRC nick: ThomasLocke
next reply other threads:[~2009-10-07 12:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 12:40 [this message]
2009-10-07 14:46 ` Ada.Directories.Base_Name and dot files Yannick Duchêne Hibou57
2009-10-07 17:06 `
2009-10-07 14:52 ` Adam Beneschan
2009-10-07 17:06 `
2009-10-07 15:10 ` Adam Beneschan
2009-10-07 15:37 ` Yannick Duchêne Hibou57
2009-10-11 2:39 ` Randy Brukardt
2009-10-07 20:11 `
2009-10-08 9:39 ` Stephen Leake
2009-10-08 9:58 `
2009-10-26 19:26 ` Type casting Bruno
2009-10-26 20:02 ` Jeffrey R. Carter
2009-10-26 20:09 ` Adam Beneschan
2009-10-26 19:27 ` Conversions Bruno
2009-10-26 20:09 ` Conversions Jeffrey R. Carter
2009-10-26 20:19 ` Conversions Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox