Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #5463 > unrolled thread
| Started by | xltardy@gmail.com |
|---|---|
| First post | 2018-06-10 20:13 -0700 |
| Last post | 2018-06-15 21:20 -0700 |
| Articles | 8 — 6 participants |
Back to article view | Back to comp.sys.acorn.programmer
Using results of a directory cataloguing xltardy@gmail.com - 2018-06-10 20:13 -0700
Re: Using results of a directory cataloguing "John Williams (News)" <UCEbin@tiscali.co.uk> - 2018-06-11 08:38 +0100
Re: Using results of a directory cataloguing Alan Adams <alan@adamshome.org.uk> - 2018-06-11 10:20 +0100
Re: Using results of a directory cataloguing jgh@mdfs.net - 2018-06-12 02:55 -0700
Re: Using results of a directory cataloguing Martin <News03@avisoft.f9.co.uk> - 2018-06-12 13:34 +0100
Re: Using results of a directory cataloguing druck <news@druck.org.uk> - 2018-06-12 18:25 +0100
Re: Using results of a directory cataloguing xltardy@gmail.com - 2018-06-15 21:04 -0700
Re: Using results of a directory cataloguing xltardy@gmail.com - 2018-06-15 21:20 -0700
| From | xltardy@gmail.com |
|---|---|
| Date | 2018-06-10 20:13 -0700 |
| Subject | Using results of a directory cataloguing |
| Message-ID | <2b768c7d-683e-4ccd-bb16-dae46badf4a6@googlegroups.com> |
Target machine : BBC A3000, RO 3.1x, BASIC program, single tasking. I want to get all the file names in a directory, to be able to further use these file names (to do batch processing). Language : BASIC (prefered) or ASM. What should I do, to get sthing like (I presume) a pointer to a list of all file names in a chosen directory ? Thanks in advance for your help.
[toc] | [next] | [standalone]
| From | "John Williams (News)" <UCEbin@tiscali.co.uk> |
|---|---|
| Date | 2018-06-11 08:38 +0100 |
| Message-ID | <570660a2afUCEbin@tiscali.co.uk> |
| In reply to | #5463 |
In article <2b768c7d-683e-4ccd-bb16-dae46badf4a6@googlegroups.com>,
Xavier Louis Tardy <xltardy@gmail.com> wrote:
> I want to get all the file names in a directory, to be able to further
> use these file names (to do batch processing). Language : BASIC
> (prefered) or ASM. What should I do, to get sthing like (I presume) a
> pointer to a list of all file names in a chosen directory ?
I quite often use EnumDir to a file as a quick and easy way of doing this:
EnumDir <Prune$Dir>.^ <Prune$Dir>.list
SetType <Prune$Dir>.list text
in the Run file of the application. Then you simply have a sequential text
list to process as you wish. Of course all objects are listed, including
directories and the application itself.
The above is from my Prune program used to delete excess back-ups.
Hope this helps,
John
--
John Williams, now back in the UK - no attachments to these addresses!
Non-RISC OS posters change user to johnrwilliams or put 'risc' in subject!
Who is John Williams? http://petit.four.free.fr/picindex/author/
[toc] | [prev] | [next] | [standalone]
| From | Alan Adams <alan@adamshome.org.uk> |
|---|---|
| Date | 2018-06-11 10:20 +0100 |
| Message-ID | <82f3690657.Alan.Adams@ArmX6.adamshome.org.uk> |
| In reply to | #5464 |
In message <570660a2afUCEbin@tiscali.co.uk>
"John Williams (News)" <UCEbin@tiscali.co.uk> wrote:
> In article <2b768c7d-683e-4ccd-bb16-dae46badf4a6@googlegroups.com>,
> Xavier Louis Tardy <xltardy@gmail.com> wrote:
>> I want to get all the file names in a directory, to be able to further
>> use these file names (to do batch processing). Language : BASIC
>> (prefered) or ASM. What should I do, to get sthing like (I presume) a
>> pointer to a list of all file names in a chosen directory ?
> I quite often use EnumDir to a file as a quick and easy way of doing this:
> EnumDir <Prune$Dir>.^ <Prune$Dir>.list
> SetType <Prune$Dir>.list text
> in the Run file of the application. Then you simply have a sequential text
> list to process as you wish. Of course all objects are listed, including
> directories and the application itself.
> The above is from my Prune program used to delete excess back-ups.
> Hope this helps,
> John
Within BASIC you can use OS_GBPB to return either one or a list of
files to process. Asking for one at a time can make your program
simpler.
Use OS_GBPB 12 with R3 set to 1 (fetch 1 entry). On return the block
will include at offset 16 the object type - 1=file, 2=directory,
3=application directory.
--
Alan Adams, from Northamptonshire
alan@adamshome.org.uk
http://www.nckc.org.uk/
[toc] | [prev] | [next] | [standalone]
| From | jgh@mdfs.net |
|---|---|
| Date | 2018-06-12 02:55 -0700 |
| Message-ID | <acecd7c9-5270-44b5-89d2-4d86775aff68@googlegroups.com> |
| In reply to | #5463 |
It's risky to demand all the filenames in a directory all at once (on any system) as you don't know beforehand how many you'll get, so could potentially fetch four billion filenames. It's best to get them one at a time and do whatever processing you want to do on each one as you go. The following is portable across any platform with an Acorn/BBC API: http://beebwiki.mdfs.net/Scanning_Directories_(Reading_Directory_Entries)
[toc] | [prev] | [next] | [standalone]
| From | Martin <News03@avisoft.f9.co.uk> |
|---|---|
| Date | 2018-06-12 13:34 +0100 |
| Message-ID | <5706ff87b4News03@avisoft.f9.co.uk> |
| In reply to | #5466 |
On 12 Jun in article
<acecd7c9-5270-44b5-89d2-4d86775aff68@googlegroups.com>,
<jgh@mdfs.net> wrote:
> It's risky to demand all the filenames in a directory all at once
> (on any system) as you don't know beforehand how many you'll get,
> so could potentially fetch four billion filenames. It's best to
> get them one at a time and do whatever processing you want to do
> on each one as you go.
Asking for *all* the files is obviously not a good thing to do,
but asking for a number with limits is fine.
> The following is portable across any platform with an Acorn/BBC API:
> http://beebwiki.mdfs.net/Scanning_Directories_(Reading_Directory_Entries)
On a BBC computer, using CALL &FFD1 to call the old BBC MOS style
OSGBPB routine would be the (only) way to go. However, the OP is
using RISC OS v3.1, and I would suggest the new-style SYS "OS_GBPB"
would be much better even though CALL &FFD1 may still work.
Using SYS "OS_GBPB" with r0=9 to 12, you can decide how much
information you want to be returned for each file, and the maximum
number of files to be returned in one call. They may both depend on
on the buffer size that you can make available. The more files at
once, the faster it will be ... but does make the program slightly
more complex.
In BASIC the simple code is based on...
max% = ??? :REM max files that might be returned
blen% = ??? :REM to hold approx max% entries
DIM buf% blen%
next% = 0
REPEAT
SYS "OS_GBPB",xx,dir$,buf%,max%,next%,blen%,name$ TO,,,read%,next%
IF read% <> 0 THEN
process buffer
ENDIF
UNTIL next% = -1
--
Martin Avison
Note that unfortunately this email address will become invalid
without notice if (when) any spam is received.
[toc] | [prev] | [next] | [standalone]
| From | druck <news@druck.org.uk> |
|---|---|
| Date | 2018-06-12 18:25 +0100 |
| Message-ID | <pfovmc$4pl$1@dont-email.me> |
| In reply to | #5466 |
On 12/06/2018 10:55, jgh@mdfs.net wrote: > It's risky to demand all the filenames in a directory all at once > (on any system) as you don't know beforehand how many you'll get, > so could potentially fetch four billion filenames. It's best to > get them one at a time and do whatever processing you want to do > on each one as you go. Attempting to reading all entries is perfectly OK, as long as... > The following is portable across any platform with an Acorn/BBC API: > http://beebwiki.mdfs.net/Scanning_Directories_(Reading_Directory_Entries) ...you use a sensible API. The above is the old Beeb style and shouldn't be used by any new code. Instead see:- https://www.riscosopen.org/wiki/documentation/show/OS_GBPB Use reason code 9,10,11 or 12 to read entries into a buffer of size you specify. If its big enough it will get all entries in one go. (Don't use 8 as you can't specify the size). Of course if the buffer isn't big enough, you need to repeat the call until all entries are read. To simplify matters people often only use a buffer large enough for one entry, and always repeat the call. ---druck
[toc] | [prev] | [next] | [standalone]
| From | xltardy@gmail.com |
|---|---|
| Date | 2018-06-15 21:04 -0700 |
| Message-ID | <632a7ee8-c252-45ee-b444-b1814d8d105a@googlegroups.com> |
| In reply to | #5468 |
Le mardi 12 juin 2018 19:25:33 UTC+2, druck a écrit : > On 12/06/2018 10:55, xxxxxxxx.net wrote: > > It's risky to demand all the filenames in a directory all at once > > (on any system) as you don't know beforehand how many you'll get, > > so could potentially fetch four billion filenames. It's best to > > get them one at a time and do whatever processing you want to do > > on each one as you go. > > Attempting to reading all entries is perfectly OK, as long as... > > > The following is portable across any platform with an Acorn/BBC API: > > http://beebwiki.mdfs.net/Scanning_Directories_(Reading_Directory_Entries) > > ...you use a sensible API. The above is the old Beeb style and shouldn't > be used by any new code. Instead see:- > > https://www.riscosopen.org/wiki/documentation/show/OS_GBPB > > Use reason code 9,10,11 or 12 to read entries into a buffer of size you > specify. If its big enough it will get all entries in one go. (Don't use > 8 as you can't specify the size). > > Of course if the buffer isn't big enough, you need to repeat the call > until all entries are read. To simplify matters people often only use a > buffer large enough for one entry, and always repeat the call. > > ---druck Thanks to all of you for your help. I think I'll have some time to try some of your solutions this week end, and will come back if I need more help. That's for my project of porting SOTB to the Archie (free advertising to my YT channel : SOTB Archie playlist is here : https://www.youtube.com/view_all_playlists )
[toc] | [prev] | [next] | [standalone]
| From | xltardy@gmail.com |
|---|---|
| Date | 2018-06-15 21:20 -0700 |
| Message-ID | <1869b96a-e6f5-4330-9204-0bc2862ae954@googlegroups.com> |
| In reply to | #5468 |
Thanks to all of you for your help. I think I'll have some time to try some of your solutions this week end, and will come back if I need more help. That's for my project of porting SOTB to the Archie (free advertising to my YT channel : SOTB Archie playlist is here : https://www.youtube.com/user/Archimedes75009/playlists )
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.acorn.programmer
csiph-web