From: dbh@doc.ic.ac.uk (Denis Howe) Newsgroups: comp.sys.acorn.tech Subject: Re: How to determine relative pathnames? Date: 21 Sep 1993 15:53:47 GMT Organization: Computing Department, Imperial College, London, UK In article <9I8lyNj024n@spuddy.UUCP> arcturus@spuddy.UUCP (Geoff Riley) asks about finding the drive containing a certain directory: >I would be most interested if anyone has a method which will work on >RiscOS 2 (this is important since a lot of Binkley users still use >RO2) as well as RiscOS 3. I believe RO3 has a new SWI for >cannonising a file name This is, I think, closely related to the problem of finding the current directory. Here is my RISC OS 2 program which does that: --------8<---------8<-------- CUT HERE --------8<---------8<-------- REM > PWD Denis Howe buflen%=256:DIM buf% buflen% CR=13:Quote$=CHR$34 SYS "OS_Args",0,0 TO FS% :REM Get temp file sys no. IF FS%=0 P."No filing system selected":END SYS "OS_FSControl",33,FS%,buf%,buflen% :REM Convert FS no. to name P%=buf%:WHILE ?P%:P%+=1:ENDWHILE:?P%=CR FS$=$buf% SYS "OS_GBPB",5,,buf% :REM Get current disk name buf%?(1+buf%?0)=CR Disc$=$(buf%+1) IF Disc$=Quote$+"Unset"+Quote$ P. "No disc selected":END Path$="" REPEAT SYS "OS_GBPB",6,,buf% :REM Get current directory leafname buf%?(2+buf%?1)=CR Leaf$=$(buf%+2) Path$="."+Leaf$+Path$ SYS "OS_FSControl",0,"^" :REM Up one level UNTIL Leaf$="$" Path$=FS$+"::"+Disc$+Path$ PRINT Path$ SYS "OS_FSControl",0,Path$ :REM Restore original directory --------8<---------8<-------- CUT HERE --------8<---------8<-------- This still works under RO3 but can be replaced by the commands Set FS SetEval CSD ":"+FileSwitch$$CSD Richard Crook wrote: >To provide a full specification you also need to determine the special >field (for example, the net fileserver number or name). >Unfortunately, there's no defined way to read this; it just has to be >reconstructed on a per-filesystem basis (under RISC OS 2, at least). >You should also note that the up-arrow character doesn't work on older >Level 4 servers - I'm not sure about newer ones. Nicko van Someren wrote: >If you alternately go to the directories '\' and '\.^' then you can >do the above without losing the previously selected directory. Maybe this should be in the FAQ? -- Denis Howe The Free On-Line Dictionary of Computing Gopher/FTP wombat.doc.ic.ac.uk (146.169.22.42) --------8<---------8<-------- CUT HERE --------8<---------8<-------- Newsgroups: comp.sys.acorn From: se2dal@dmu.ac.uk (Dave Lodge) Subject: yet another pwd utility Organization: De Montfort University, Leicester, UK Date: Wed, 13 Oct 1993 11:52:45 GMT Having recently down-loaded 2 programs from Newcy to emulate the Unix `pwd' command, and seeing the sizes (30k (!) and 330 bytes) I decided to write my own. This version only takes up 86 bytes, when assembled. It is unfortunately only RO3, so if you want a RO2 pwd - I suggest using another one of the utilities on Newcy. This uses one of the `new' RO3 FS_Control calls: FSControl_CanoncalisePath (I love that name!) This code works by first calling FSControl to get the size of the pathname, then it uses os_module to reserve that space - then it uses that space to call FSControl again. It cd be compacted by removing the first FSControl call and instead placing 256 in R3 when you call OS_Module (all pathnames are less than 256!) Dave REM>Sml pwd program REM RO3 and later only REM By Dave Lodge : DIM code 1000 FOR ION=4 TO 6 STEP 2 P%=0:O%=code [OPTION .pwd stmfd 13!,{0-5,14} adr 1,current mov 0,#37:mov 2,#0:mov 3,#0:mov 4,#0:mov 5,#0 swi "OS_FSControl" ; get size of buffer mov 3,#1:sub 3,3,5:mov 5,3:mov 0,#6 swi "OS_Module" ; reserve memory mov 0,#37 swi "OS_FSControl" ; get path mov 0,2:swi "OS_Write0":swi "OS_NewLine" ; print path mov 0,#7:swi "OS_Module" ; release memory ldmfd 13!,{0-5,pc}^ .current :="@":=0 ]:NEXT SYS "OS_File",10,":0.pwd",&ffc,,code,O%