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-7-bit X-Google-Thread: 103376,3b009bb3a08ff095 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-17 09:48:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!fu-berlin.de!uni-berlin.de!ppp-5-119.5800-8.access.uk.worldonline.COM!not-for-mail From: "Nick Roberts" Newsgroups: comp.lang.ada Subject: Re: file list in a directory Date: Sat, 17 Mar 2001 17:45:55 -0000 Message-ID: <9907tp$3ula5$1@ID-25716.news.dfncis.de> References: NNTP-Posting-Host: ppp-5-119.5800-8.access.uk.worldonline.com (62.64.167.119) X-Trace: fu-berlin.de 984851194 4150597 62.64.167.119 (16 [25716]) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: supernews.google.com comp.lang.ada:5806 Date: 2001-03-17T17:45:55+00:00 List-Id: Is there a working doucment on this on the Internet anywhere? One idea that occurred to me as to how an implementation could supply this sort of facility, without actually requiring a special package, would be to provide a special syntax for the file name when opening or creating a text file, where the relevant names or other data/parameters were output/input as lines of text. For example: with Ada.Text_IO; use Ada.Text_IO; procedure List_Ada is Name: String(1..200); Last: Natural; Search: File_Type; begin Open(Search,In_File,"dir:*.ads;*.adb//source/ada/"); Get_Line(Search,Name,Last); Put_Line(Name(1..Last)); Close(Search); end; Operations such as copying, linking, archiving/backup, and inquiry and update of attributes could be provided in a similar way. This technique makes use of the file I/O idiom to provide a ready iterator. In particular it says when a single search begins and ends (at opening and closing), so that the list can be 'frozen' (or the directory locked) during the search. It could also help with debugging, and help facilitate ersatz functionality. Obviously, a definition of a standard name syntax would be advantageous. This would be a technique that could have the advantage of being largely language-independent. A copying example might be: with Ada.Text_IO; use Ada.Text_IO; procedure Copy_Safely is Name: String(1..200); Last: Natural; Search, Copier: File_Type; begin Open(Search,In_File,"dir:*.ads;*.adb//source/ada/"); Create(Copier,Out_File,"copy:|//source/ada"); Get_Line(Search,Name,Last); Put_Line(Copier, Name(1..Last) & "|backup/" & Name(1..Last) ); Close(Search); Close(Copier); end; When the Copier file is closed, the copy operations are performed, preferably with all-or-nothing semantics (if something goes wrong, an exception is raised). NB: These examples don't have the checking they should. -- Nick Roberts http://www.AdaOS.org "Robert A Duff" wrote in message news:wccelvxqxrj.fsf@world.std.com... > Pascal Obry writes: > > > Ada can't do that. Some program just don't have access to a file system > > (e.g. embedded programs). > > Not a very good excuse, I think. Ada has Text_IO, after all. > > The ARG is working on a portable (standard) Directory_Operations > package, but it won't happen quickly. > > - Bob