comp.lang.ada
 help / color / mirror / Atom feed
* Ada.Directories.Base_Name and dot files
@ 2009-10-07 12:40 
  2009-10-07 14:46 ` Yannick Duchêne Hibou57
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From:  @ 2009-10-07 12:40 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 19+ messages in thread
* Conversions
@ 2000-03-16  0:00 Karlene Johnson
  2000-03-16  0:00 ` Conversions Marin D. Condic
  0 siblings, 1 reply; 19+ messages in thread
From: Karlene Johnson @ 2000-03-16  0:00 UTC (permalink / raw)


I am trying to convert an Float number to an Integer number, after a
calculation with 2 Float numbers.  Any suggesions on how to convert??




^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2009-10-26 20:19 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-07 12:40 Ada.Directories.Base_Name and dot files 
2009-10-07 14:46 ` 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
  -- strict thread matches above, loose matches on Subject: below --
2000-03-16  0:00 Conversions Karlene Johnson
2000-03-16  0:00 ` Conversions Marin D. Condic

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