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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!feed118.news.tele.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Wed, 07 Oct 2009 14:40:00 +0200 From: =?ISO-8859-1?Q?Thomas_L=F8cke?= <"tl at ada-dk.org"> Organization: Ada DK User-Agent: Thunderbird 2.0.0.23 (X11/20090812) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Ada.Directories.Base_Name and dot files Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4acc8c20$0$284$14726298@news.sunsite.dk> NNTP-Posting-Host: 83.91.213.86 X-Trace: news.sunsite.dk DXC=f?7@H:;e39Ia0CAcDd;B0AYSB=nbEKnkKcmNRUa7T1LN9HanD:b=JLA=UiO>Z:P6OCaX>>FJ?M`3H>iVX^m`5j8E^E5PF7hS5NG X-Complaints-To: staff@sunsite.dk Xref: g2news2.google.com comp.lang.ada:8600 Date: 2009-10-07T14:40:00+02:00 List-Id: 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