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-Thread: 103376,6bf1c4b845bd2160 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news3.google.com!feeder.news-service.com!feeder.news-service.com!news.osn.de!diablo2.news.osn.de!news.belwue.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 26 Aug 2010 02:59:25 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: What about a glob standard method in Ada.Command_Line ? References: <152a2z5en4z2o$.xjsuqr7s8yak$.dlg@40tude.net> <4c73e859$0$6991$9b4e6d93@newsspool4.arcor-online.net> <4c73fcf6$0$6992$9b4e6d93@newsspool4.arcor-online.net> <1jxm50y65grlo.sjyb9hm4y1xp$.dlg@40tude.net> <4c743a59$0$6893$9b4e6d93@newsspool2.arcor-online.net> <4c74db09$0$6890$9b4e6d93@newsspool2.arcor-online.net> <1r82cxcws3pc9$.r40m8l3ttil7$.dlg@40tude.net> <4c74f9f6$0$6772$9b4e6d93@newsspool3.arcor-online.net> <17drl4b1ko4iv.1eccfudluzl5h.dlg@40tude.net> <4c7515fc$0$7664$9b4e6d93@newsspool1.arcor-online.net> <4c752693$0$7656$9b4e6d93@newsspool1.arcor-online.net> <17uj112bzfc47$.1jlqotsp6zuup.dlg@40tude.net> <4c753c0c$0$6877$9b4e6d93@newsspool2.arcor-online.net> <4c756481$0$6775$9b4e6d93@newsspool3.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4c75bc6d$0$6973$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 26 Aug 2010 02:59:25 CEST NNTP-Posting-Host: 6fc0bb05.newsspool4.arcor-online.net X-Trace: DXC=l=XC8cCGjkEFJ3]dH>I?oE4IUKejVHXb=H:M_cDN@ZF37Qd@g]QK X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:13749 Date: 2010-08-26T02:59:25+02:00 List-Id: On 8/25/10 9:39 PM, Dmitry A. Kazakov wrote: >> "*" -> Search -> Match (file name pattern) -> ... > > What does this have to do with legality of names with spaces? > > How could it help to implement search for all files matched by a*¶? I'm beginning to feel I have once again missed the proper references for the meaning of words in our discussion. You said, "You just do not need patterns in directory search." Did this refer to the Pattern : String parameter of (Start_)Search? If so, I fully agree. Here is what I wanted Matcher : access function (...) to be. 1. get rid of implementation-defined Pattern : String 2. do with the names what I want after they have been read: For example, call a function matching a name against some RE pattern 3. delegate the calling to (Start_)Search (Otherwise, everything is pretty much like Search.) Filenames "as is" means whatever the OS or run-time passes to (Start_)Search, something that can be passed to other operations that require a file name. String is a most flexible data structure for file names because it can store any kind of file name which I take to be a sequence of bits. One could use Wide_Wide_String or Storage_Element_Array for a file name as long as no attempt is made to attribute meaning to file name other than an ordered sequence of bits that identifies a file. Anything more is wishful thinking. Character strings are just more practical than bit patterns or number sequences. IOW, I simply do not care what standard meaning one might attribute to the sequence of bytes that comes in. If it needs to be shown to a user, then "appropriate conversion", in a best effort sense, is probably best, from bit string to some other string. When I said that case insensitivity is handled by RE pattern matching, I did not mean that issues like moving collections of files between case-sensitive and case-insensitive file systems can be handled by RE pattern matching. I still can't figure out why you have been referring to Name_Error. The file names considered by my Start_Search variant necessarily identify existing files. In this sense, exceptions caused by anything to do with existing file's names will not seem acceptable. Here is code looking for a file named "aö" on a number of file systems. Source file encoding should be Latin-1. with Ada.Text_IO; with Ada.Directories; procedure Filenames is Not_Found_Error : exception; procedure Show_String (S: String); -- tabular display of Characters in S, with hex codes function Find_Odd_Name return String; -- Look for a file named "aö" and return the characters of this name. -- Raises Not_Found_Error function Find_Odd_Name return String is use Ada.Directories; Search_For_Aö : Search_Type; Dir_Entry : Directory_Entry_Type; Aö8 : constant String := "aö"; -- UTF-8 AöL : constant String := "aö"; -- Latin-1 AöN : constant String := "ao" & Character'Val (16#CC#) & Character'Val (16#88#); -- NFD (HFS+) begin Start_Search (Search => Search_For_Aö, Directory => "News", Pattern => "*"); loop exit when not More_Entries (Search_For_Aö); Get_Next_Entry (Search_For_Aö, Dir_Entry); declare Name : constant String := Simple_Name (Dir_Entry); begin if Name = Aö8 or Name = AöL or Name = AöN then End_Search(Search_For_Aö); return Name; end if; end; end loop; raise Not_Found_Error; end Find_Odd_Name; procedure Show_String (S: String) is package Hex_IO is new Ada.Text_IO.Integer_IO (Natural); begin Hex_IO.Default_Base := 16; for K in S'Range loop Ada.Text_IO.Put (S(K)); Hex_IO.Put (Character'Pos(S(K))); Ada.Text_IO.New_Line; end loop; end Show_String; begin declare Filename : constant String := Find_Odd_Name ; begin Show_String(Filename); end ; end Filenames; -- Georg