* file list in a directory @ 2001-03-16 18:19 EtienneB 2001-03-16 18:31 ` Pascal Obry ` (3 more replies) 0 siblings, 4 replies; 18+ messages in thread From: EtienneB @ 2001-03-16 18:19 UTC (permalink / raw) How can get it in Ada ? Thanks Etienne Baudin ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 18:19 file list in a directory EtienneB @ 2001-03-16 18:31 ` Pascal Obry 2001-03-16 20:12 ` Robert A Duff 2001-03-16 19:07 ` tmoran ` (2 subsequent siblings) 3 siblings, 1 reply; 18+ messages in thread From: Pascal Obry @ 2001-03-16 18:31 UTC (permalink / raw) "EtienneB" <etienne.baudin@wanadoo.fr> writes: > How can get it in Ada ? Ada can't do that. Some program just don't have access to a file system (e.g. embedded programs). You can do this with POSIX (Florist for UNIX and POSIX-Win32 from my homepage). If you use GNAT look for GNAT.Directory_Operations. Other compilers certainly provide this features, read the doc :) Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://perso.wanadoo.fr/pascal.obry --| --| "The best way to travel is by means of imagination" ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 18:31 ` Pascal Obry @ 2001-03-16 20:12 ` Robert A Duff 2001-03-17 10:09 ` Pascal Obry 2001-03-17 17:45 ` Nick Roberts 0 siblings, 2 replies; 18+ messages in thread From: Robert A Duff @ 2001-03-16 20:12 UTC (permalink / raw) Pascal Obry <p.obry@wanadoo.fr> 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 20:12 ` Robert A Duff @ 2001-03-17 10:09 ` Pascal Obry 2001-03-17 17:45 ` Nick Roberts 1 sibling, 0 replies; 18+ messages in thread From: Pascal Obry @ 2001-03-17 10:09 UTC (permalink / raw) Robert A Duff <bobduff@world.std.com> writes: > Pascal Obry <p.obry@wanadoo.fr> 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. This is not excuse just my understanding of why so much libraries are missing in Ada. Ada95 is better in this respect than Ada83 but yet many interfaces to the file system, windowing system, screen control are still missing. Indeed this should be fixed, now we have a specific Annex for Information Systems but just can't get the list of files in a directory :) Anyway, nice to hear that this is worked on. Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://perso.wanadoo.fr/pascal.obry --| --| "The best way to travel is by means of imagination" ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 20:12 ` Robert A Duff 2001-03-17 10:09 ` Pascal Obry @ 2001-03-17 17:45 ` Nick Roberts 2001-03-17 18:08 ` Randy Brukardt ` (2 more replies) 1 sibling, 3 replies; 18+ messages in thread From: Nick Roberts @ 2001-03-17 17:45 UTC (permalink / raw) 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" <bobduff@world.std.com> wrote in message news:wccelvxqxrj.fsf@world.std.com... > Pascal Obry <p.obry@wanadoo.fr> 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 ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-17 17:45 ` Nick Roberts @ 2001-03-17 18:08 ` Randy Brukardt 2001-03-17 19:57 ` Georg Bauhaus 2001-03-19 10:46 ` Jean-Pierre Rosen 2 siblings, 0 replies; 18+ messages in thread From: Randy Brukardt @ 2001-03-17 18:08 UTC (permalink / raw) Nick Roberts wrote in message <9907tp$3ula5$1@ID-25716.news.dfncis.de>... >Is there a working doucment on this on the Internet anywhere? This is AI-248. (www.ada-auth.org/ais.html) I still have to revise it with the suggestions from the last meeting. You're welcome to send comments directly to me. Randy Brukardt. ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-17 17:45 ` Nick Roberts 2001-03-17 18:08 ` Randy Brukardt @ 2001-03-17 19:57 ` Georg Bauhaus 2001-03-19 10:46 ` Jean-Pierre Rosen 2 siblings, 0 replies; 18+ messages in thread From: Georg Bauhaus @ 2001-03-17 19:57 UTC (permalink / raw) Nick Roberts (nickroberts@adaos.worldonline.co.uk) wrote: : Open(Search,In_File,"dir:*.ads;*.adb//source/ada/"); That would mean a directory is nothing more than a list of file names... ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-17 17:45 ` Nick Roberts 2001-03-17 18:08 ` Randy Brukardt 2001-03-17 19:57 ` Georg Bauhaus @ 2001-03-19 10:46 ` Jean-Pierre Rosen 2001-04-08 3:18 ` srini 2 siblings, 1 reply; 18+ messages in thread From: Jean-Pierre Rosen @ 2001-03-19 10:46 UTC (permalink / raw) Have a look at package OS_Services, which is available from Adalog's components page at http://www.adalog.fr/compo2.htm -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-19 10:46 ` Jean-Pierre Rosen @ 2001-04-08 3:18 ` srini 2001-04-09 9:34 ` Jean-Pierre Rosen 0 siblings, 1 reply; 18+ messages in thread From: srini @ 2001-04-08 3:18 UTC (permalink / raw) How about gnat.directory_operations from gnat. I have had good success with it. This in combination with gnat.command_line perform most directory related services one might require. I hope any enhancements to the Ada package hierarchy would mirror these packages. Jean-Pierre Rosen wrote: > > Have a look at package OS_Services, which is available from Adalog's components page at http://www.adalog.fr/compo2.htm > > -- > --------------------------------------------------------- > J-P. Rosen (rosen@adalog.fr) > Visit Adalog's web site at http://www.adalog.fr ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-04-08 3:18 ` srini @ 2001-04-09 9:34 ` Jean-Pierre Rosen 0 siblings, 0 replies; 18+ messages in thread From: Jean-Pierre Rosen @ 2001-04-09 9:34 UTC (permalink / raw) [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 1115 bytes --] "srini" <r.srinivasan@worldnet.att.net> a �crit dans le message news: 3AD153E2.D03565FC@worldnet.att.net... > How about gnat.directory_operations from gnat. I have had good success > with it. This in combination with gnat.command_line perform most > directory related services one might require. I hope any enhancements to > the Ada package hierarchy would mirror these packages. > It's fine, but supported only by Gnat. Actually, one of the implementations of OS_Services is built on top of these packages. Also, OS_Services is intended to be flexible and extensible, i.e. allow you to benefit from OS pecularities, while still providing a hard kernel of operations that work on every OS. The way it is designed, if you try to use a feature that is not available on your OS, the program will simply not compile. (Put it the other way round: if it compiles, it works). And it avoids the "least common denominator" problem when you want a portable interface. -- --------------------------------------------------------- J-P. Rosen (rosen@adalog.fr) Visit Adalog's web site at http://www.adalog.fr ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 18:19 file list in a directory EtienneB 2001-03-16 18:31 ` Pascal Obry @ 2001-03-16 19:07 ` tmoran 2001-03-16 21:19 ` EtienneB 2001-03-16 21:19 ` EtienneB 2001-03-19 9:23 ` Martin Dowie 3 siblings, 1 reply; 18+ messages in thread From: tmoran @ 2001-03-16 19:07 UTC (permalink / raw) >How can get it in Ada ? That's an OS question. If you are using MS Windows, you can look at Claw.Directories in the intro version downloadable from www.rrsoftware.com ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 19:07 ` tmoran @ 2001-03-16 21:19 ` EtienneB 2001-03-17 0:53 ` David C. Hoos, Sr. ` (2 more replies) 0 siblings, 3 replies; 18+ messages in thread From: EtienneB @ 2001-03-16 21:19 UTC (permalink / raw) To: comp.lang.ada So, I tryed quickly to do it interfacing with but the linker did't agree ./test_rep.o(.text+0x3e):test_rep.adb: undefined reference to `_opendir' ./test_rep.o(.text+0x4f):test_rep.adb: undefined reference to `readDir' ./test_rep.o(.text+0x60):test_rep.adb: undefined reference to `closeDir' gnatmake: *** link failed. look at the imports function openDir (szPath : chars_ptr) return dir_access; pragma import (C, openDir, "_opendir"); function closeDir (Dir : dir_access) return integer; pragma import (C, closeDir, "closeDir"); function readDir (Dir : dir_access) return dirent_access; pragma import (C, readDir, "readDir"); Thanks Etienne Baudin ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 21:19 ` EtienneB @ 2001-03-17 0:53 ` David C. Hoos, Sr. 2001-03-17 2:50 ` DuckE 2001-03-17 10:10 ` Pascal Obry 2 siblings, 0 replies; 18+ messages in thread From: David C. Hoos, Sr. @ 2001-03-17 0:53 UTC (permalink / raw) You have to tell the linker in which library unit to find the missing functions. This is done (for example) by adding -largs -L <library-directory> -l<abbreviated-library-file-name> where the abbreviated <library-file-name> is formed by removing "lib" from the beginning of the full file name, and removing ".a" from the end of the full file name. "EtienneB" <etienne.baudin@wanadoo.fr> wrote in message news:mailman.984777550.11120.comp.lang.ada@ada.eu.org... > So, I tryed quickly to do it interfacing with but the linker did't agree > > ./test_rep.o(.text+0x3e):test_rep.adb: undefined reference to `_opendir' > ./test_rep.o(.text+0x4f):test_rep.adb: undefined reference to `readDir' > ./test_rep.o(.text+0x60):test_rep.adb: undefined reference to `closeDir' > gnatmake: *** link failed. > > look at the imports > function openDir (szPath : chars_ptr) return dir_access; > pragma import (C, openDir, "_opendir"); > function closeDir (Dir : dir_access) return integer; > pragma import (C, closeDir, "closeDir"); > function readDir (Dir : dir_access) return dirent_access; > pragma import (C, readDir, "readDir"); > > Thanks > Etienne Baudin > > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 21:19 ` EtienneB 2001-03-17 0:53 ` David C. Hoos, Sr. @ 2001-03-17 2:50 ` DuckE 2001-03-17 12:30 ` Staffan Dittmer 2001-03-17 10:10 ` Pascal Obry 2 siblings, 1 reply; 18+ messages in thread From: DuckE @ 2001-03-17 2:50 UTC (permalink / raw) "EtienneB" <etienne.baudin@wanadoo.fr> wrote in message news:mailman.984777550.11120.comp.lang.ada@ada.eu.org... > So, I tryed quickly to do it interfacing with but the linker did't agree > > ./test_rep.o(.text+0x3e):test_rep.adb: undefined reference to `_opendir' > ./test_rep.o(.text+0x4f):test_rep.adb: undefined reference to `readDir' > ./test_rep.o(.text+0x60):test_rep.adb: undefined reference to `closeDir' > gnatmake: *** link failed. > Since you're using GNAT, you might want to have a look at the GNAT specific package: GNAT.Directory_Operations On my W2K installation it is located in the file named: g-dirope.ads. SteveD > look at the imports > function openDir (szPath : chars_ptr) return dir_access; > pragma import (C, openDir, "_opendir"); > function closeDir (Dir : dir_access) return integer; > pragma import (C, closeDir, "closeDir"); > function readDir (Dir : dir_access) return dirent_access; > pragma import (C, readDir, "readDir"); > > Thanks > Etienne Baudin > > ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-17 2:50 ` DuckE @ 2001-03-17 12:30 ` Staffan Dittmer 0 siblings, 0 replies; 18+ messages in thread From: Staffan Dittmer @ 2001-03-17 12:30 UTC (permalink / raw) In article <9iAs6.580631$U46.17301137@news1.sttls1.wa.home.com>, "DuckE" <nospam_steved94@home.com> writes: > > Since you're using GNAT, you might want to have a look at the GNAT specific > package: > GNAT.Directory_Operations > > On my W2K installation it is located in the file named: g-dirope.ads. > > SteveD There are some GNAT specific source code examples at www.adapower.com. One of which deals with GNAT.Directory_Operations. See http://www.adapower.com/lang/index.html /Staffan ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 21:19 ` EtienneB 2001-03-17 0:53 ` David C. Hoos, Sr. 2001-03-17 2:50 ` DuckE @ 2001-03-17 10:10 ` Pascal Obry 2 siblings, 0 replies; 18+ messages in thread From: Pascal Obry @ 2001-03-17 10:10 UTC (permalink / raw) "EtienneB" <etienne.baudin@wanadoo.fr> writes: > So, I tryed quickly to do it interfacing with but the linker did't agree > > ./test_rep.o(.text+0x3e):test_rep.adb: undefined reference to `_opendir' > ./test_rep.o(.text+0x4f):test_rep.adb: undefined reference to `readDir' > ./test_rep.o(.text+0x60):test_rep.adb: undefined reference to `closeDir' > gnatmake: *** link failed. See my answer in fr.comp.lang.ada. Pascal. -- --|------------------------------------------------------ --| Pascal Obry Team-Ada Member --| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE --|------------------------------------------------------ --| http://perso.wanadoo.fr/pascal.obry --| --| "The best way to travel is by means of imagination" ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 18:19 file list in a directory EtienneB 2001-03-16 18:31 ` Pascal Obry 2001-03-16 19:07 ` tmoran @ 2001-03-16 21:19 ` EtienneB 2001-03-19 9:23 ` Martin Dowie 3 siblings, 0 replies; 18+ messages in thread From: EtienneB @ 2001-03-16 21:19 UTC (permalink / raw) So, I tryed quickly to do it interfacing with but the linker did't agree ./test_rep.o(.text+0x3e):test_rep.adb: undefined reference to `_opendir' ./test_rep.o(.text+0x4f):test_rep.adb: undefined reference to `readDir' ./test_rep.o(.text+0x60):test_rep.adb: undefined reference to `closeDir' gnatmake: *** link failed. look at the imports function openDir (szPath : chars_ptr) return dir_access; pragma import (C, openDir, "_opendir"); function closeDir (Dir : dir_access) return integer; pragma import (C, closeDir, "closeDir"); function readDir (Dir : dir_access) return dirent_access; pragma import (C, readDir, "readDir"); Thanks Etienne Baudin ^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: file list in a directory 2001-03-16 18:19 file list in a directory EtienneB ` (2 preceding siblings ...) 2001-03-16 21:19 ` EtienneB @ 2001-03-19 9:23 ` Martin Dowie 3 siblings, 0 replies; 18+ messages in thread From: Martin Dowie @ 2001-03-19 9:23 UTC (permalink / raw) If you're using Unix, something like this has worked for me in the past (no guarantees here, I'm on a Windohs machine just now and this is from memory :-) procedure Command_Line is function C_System (Value : String) return Integer; pragma Import (C, C_System, "System"); Result : integer; begin Result := C_System (Value => "ls > ./temp.txt"); end Command_Line; EtienneB <etienne.baudin@wanadoo.fr> wrote in message news:AOss6.124$76.376857@nnrp1.proxad.net... > How can get it in Ada ? > Thanks > Etienne Baudin > > ^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2001-04-09 9:34 UTC | newest] Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-03-16 18:19 file list in a directory EtienneB 2001-03-16 18:31 ` Pascal Obry 2001-03-16 20:12 ` Robert A Duff 2001-03-17 10:09 ` Pascal Obry 2001-03-17 17:45 ` Nick Roberts 2001-03-17 18:08 ` Randy Brukardt 2001-03-17 19:57 ` Georg Bauhaus 2001-03-19 10:46 ` Jean-Pierre Rosen 2001-04-08 3:18 ` srini 2001-04-09 9:34 ` Jean-Pierre Rosen 2001-03-16 19:07 ` tmoran 2001-03-16 21:19 ` EtienneB 2001-03-17 0:53 ` David C. Hoos, Sr. 2001-03-17 2:50 ` DuckE 2001-03-17 12:30 ` Staffan Dittmer 2001-03-17 10:10 ` Pascal Obry 2001-03-16 21:19 ` EtienneB 2001-03-19 9:23 ` Martin Dowie
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox