home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-01-08 | 2.7 KB | 89 lines |
- Screen Open 0,640,200,2,Hires : Colour 1,$FFF : Curs Off
- Reserve As Work 5,260
- Global FILEINFOBLOCK
- FILEINFOBLOCK=Start(5)
- GTDR["sys:"]
- Procedure GTDR[DR$]
- PATH$=DR$
- LOCK[PATH$,-2]
- LOCK=Param
- If LOCK=0
- 'if we continue without the lock we will get a very nasty guru
- Print
- Centre "Warning!! Unable to obtain lock for "+PATH$
- Print
- Direct
- End If
- EXAMINE[LOCK,FILEINFOBLOCK]
- STATUS=Param
- While STATUS<>0
- 'is entry file or another directory
- If Leek(FILEINFOBLOCK+4)>0
- TYPE$="Dir" : Else TYPE$="File" : End If
- ' the file name is a null terminated string
- FILE$=String$(Chr$(0),108)
- Copy FILEINFOBLOCK+8,FILEINFOBLOCK+116 To Varptr(FILE$)
- FILE$=Left$(FILE$,Instr(FILE$,Chr$(0))-1)
- ' same for comment
- COMMENT$=String$(Chr$(0),80)
- Copy FILEINFOBLOCK+144,FILEINFOBLOCK+224 To Varptr(COMMENT$)
- COMMENT$=Left$(COMMENT$,Instr(COMMENT$,Chr$(0))-1)
- ' file size in bytes & blocks
- SIZE=Leek(FILEINFOBLOCK+124)
- NUMBLOCKS=Leek(FILEINFOBLOCK+128)
- ' get date & format it
- DAYS=Leek(FILEINFOBLOCK+132)
- N=DAYS-2251 : Y=(4*N+3)/1461 : NN=N-(1461*Y)/4 : YY=Y+1984 : M=(5*NN+2)/153
- D=NN-(153*M+2)/5+1 : MM=M+3
- If MM>12 : Inc YY : MM=MM-12 : End If
- DATE$=Str$(D)+"/"
- If D<10 : DATE$="0"+DATE$ : End If
- If MM<10
- DATE$=DATE$+"0"+Str$(MM)+"/"+Right$(Str$(YY),2)
- Else
- DATE$=DATE$+Str$(MM)+"/"+Right$(Str$(YY),2)
- End If
- DATE$=DATE$-" "
- ' get the time and format it
- MM=Leek(FILEINFOBLOCK+136) : HH=MM/60 : MM=MM mod 60
- If HH<10 : TIME$="0"+Str$(HH)-" "+":" : Else TIME$=Str$(HH)-" "+":" : End If
- If MM<10 : TIME$=TIME$+"0"+Str$(MM)-" " : Else TIME$=TIME$+Str$(MM)-" " : End If
- ' get file protection bits
- PB$="____RWED" : PB=Leek(FILEINFOBLOCK+116)
- For I=0 To 3
- If Btst(I,PB) : Mid$(PB$,8-I,1)="_" : End If
- Next I
- If Btst(4,PB) Then Mid$(PB$,4)="A"
- If Btst(5,PB) Then Mid$(PB$,3)="P"
- If Btst(6,PB) Then Mid$(PB$,2)="S"
- If Btst(7,PB) Then Mid$(PB$,1)="H"
- EXNEXT[LOCK,FILEINFOBLOCK]
- STATUS=Param : Rem a status of 0 indicates that there are no more files
- If STATUS<>0
- Print "Filename:-";FILE$;"(";TYPE$;")"
- Print "Size:-";SIZE;" Number of blocks:-";NUMBLOCKS
- Print "Protection bits:-";PB$
- Print "Date:-";DATE$;" Time:-";TIME$
- Print "Comment:-";COMMENT$
- Print
- Wait Key
- End If
- Wend
- UNLOCK[LOCK]
- End Proc
- Procedure LOCK[NAME$,MOAD]
- ' moad takes the value -2 for read -1 for write
- ' the name$ must be nul terminated
- NAME$=NAME$+Chr$(0) : Dreg(1)=Varptr(NAME$) : Dreg(2)=MOAD
- End Proc[Doscall(-84)]
- Procedure EXAMINE[LOCK,FILEINFOBLOCK]
- 'parameters are pointers to the lock & pointers to the fileinfoblock
- Dreg(1)=LOCK : Dreg(2)=FILEINFOBLOCK
- End Proc[Doscall(-102)]
- Procedure EXNEXT[LOCK,FILEINFOBLOCK]
- 'parameters are pointers to the lock & pointers to the fileinfoblock
- Dreg(1)=LOCK : Dreg(2)=FILEINFOBLOCK
- End Proc[Doscall(-108)]
- Procedure UNLOCK[LOCK]
- Dreg(1)=LOCK
- End Proc[Doscall(-90)]