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!news3.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: Thu, 08 Oct 2009 11:58:01 +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: Re: Ada.Directories.Base_Name and dot files References: <4acc8c20$0$284$14726298@news.sunsite.dk> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4acdb7aa$0$283$14726298@news.sunsite.dk> NNTP-Posting-Host: 83.91.213.86 X-Trace: news.sunsite.dk DXC=3D4fOef=CPS;OkaSc<8a?TYSB=nbEKnk[cWN^LcTk:7V9HanD:b=JLQ=UiO>Z:P6OSaX>>FJ?M`3XBQG\YY8lVMUgBIOXZejNHX X-Complaints-To: staff@sunsite.dk Xref: g2news2.google.com comp.lang.ada:8624 Date: 2009-10-08T11:58:01+02:00 List-Id: Stephen Leake wrote: > Thomas L�cke <"tl at ada-dk.org"> writes: > >> 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 >> ++++ > > Just out of curiosity, what made you hope for this? The Gnu coreutils > basename function doesn't do what you want, either: Yes, that was actually a typo. I was hoping for the same behavior as basename, as shown in your output below. In my haste, I just forgot to add the .bar part to output line 3: .foo I was too focused on the second line, where .foo was completely eliminated. > > $ basename foo.txt > foo.txt > $ basename foo.txt .txt > foo > $ basename .foo > .foo > $ basename .foo .foo > .foo > $ basename .foo.bar > .foo.bar > $ basename .foo.bar .bar > .foo > $ basename .foo.bar .foo > .foo.bar > $ basename .foo.bar .foo.bar > .foo.bar > > >> With the current null string solution, you'd have to do some manual >> parsing to get to the actual basename of a dot file. > > What is your definition of "the actual basename"? On my Linux system, my definition of the basename, is the name returned by basename. > >> Is there a good reason for the current behavior? > > It's well-defined. And it does what I want :). > I've read the link posted by Adam, and it has made me a lot wiser in regards to this issue. I feel I now have a better understanding of why Ada.Directories.Base_Name does what it does. So I guess I now also think that it is both well-defined and that it does what I didn't knew I wanted. :o) -- Regards, Thomas L�cke Email: tl at ada-dk.org Web: http:ada-dk.org IRC nick: ThomasLocke