Tiens, j'ai mis des commentaires:
;SYM_ENTRY *SymFindFirst (SYM_STR SymName, unsigned short Flags);
SymFindFirst:
moveq #3,d0 ; Mask to save the flags we want
and.w 8(a7),d0 ; Read the Flags
move.w d0,SYMFIND_FLAGS ; Save flags as global (Forget temp, twin, return_folder and collapse)
cmp.w #FO_SINGLE_FOLDER,d0 ; Check if recursive scan or folder scan
bne.s \Home
move.l 4(a7),a1 ; Read the Folder Name
move.l a1,d0 ; If NULL => Home directory
beq.s \Home
\cvt: tst.b -(a1) ; Convert the SYM_STR to a standard str
bne.s \cvt
addq.l #1,a1
cmpi.b #$7F,(a1) ; Is it the Home Name ?
beq.s \Home ; yes
move.w #FOLDER_LIST_HANDLE,a0 ; Folder Handle in a0
bsr FindSymEntry ; Find the requested folder in the folder list
move.l a0,d0 ; Check if
beq.s SymFindNextError ; successfull
move.w SYM_ENTRY.hVal(a0),a0 ; Read its handle
bra.s \folder
\Home: move.w #FOLDER_LIST_HANDLE,a0 ; Folder Handle in a0
\folder:
; Get the first entry in the folder 'a0'
trap #3 ; Deref it
addq.l #2,a0 ; Skip MAX item
move.w (a0)+,d1 ; Read the number of files
bsr Sym2HSym ; Get the first SYM_ENTRY (a0 -> d0)
tst.w d1 ; No file in folder ?
beq.s SymFindNextError ; Yes so report an error
move.l d0,SYMFIND_HSYM ; Save the current scanned file for future use.
rts
SymFindNextError:
clr.l SYMFIND_HSYM
suba.l a0,a0
rts
;SYM_ENTRY *SymFindNext (void);
SymFindNext:
suba.l a0,a0
move.l SYMFIND_HSYM,d0 ;Read the current scanned file
beq.s SymFindNextError ;If there is no saved file, report an error
cmpi.w #2,SYMFIND_FLAGS ; Check if we have to do a recursive scan or not.
bne.s \NoRecurse
;; Check if the current scanned file is a folder.
;; If so, we have to go down the folder to get its first entry
;; If no, we have to continue scanning the folder.
bsr DerefSym_Reg ; a0 -> SYM_ENTRY of the file / a1 -> Folder
move.w SYM_ENTRY.flags(a0),d1
andi.w #SF_FOLDER,d1 ; Not a folder, so no recurse
beq.s \NoRecurse
;; The scanned file is a folder and we are in recursive mode:
;; Return the first file of the folder
; Go down the folder : first entry
move.w SYM_ENTRY.hVal(a0),a0
trap #3
addq.l #2,a0
move.w (a0)+,d1
bsr Sym2HSym ; First entry
move.l d0,SYMFIND_HSYM ; Save HSYM (FIXME?)
tst.w d1 ; Check if there is no file
beq.s \EndOfFolder ;
rts
;; An error (end of folder) was reported.
;; If we are not in recursive mode, it is the end of SymFindNext
\EndOfFolder:
cmpi.w #2,SYMFIND_FLAGS ; Recurse
bne.s SymFindNextError
;; In recursive mode, we have to go to the next folder
move.l SYMFIND_HSYM,d0 ; Read the scanned file
bsr FindFolderHSymFromFileHSym_Reg ; Get the Folder high from the scanned file
; Next Hsym in folder table
add.w #SYM_ENTRY.sizeof,d0 ; Increment the HSYM to get the next item in the folder table
move.l d0,SYMFIND_HSYM ; Save it (FIXME ?)
bsr DerefSym_Reg ; d0 -> a0 -> SYM_ENTRY of the folder / a1 -> Folder Home
move.l a0,d0 ; Check if successful
beq.s SymFindNextError ; No report an error
rts
;; We don't have to do a recursive scan.
;; Increment the HSYM by the size of an item to get a new item.
;; Deref it (If the HSYM was out or range, the deref function returns NULL).
;; If we have reached the end of the folder, report an error.
\NoRecurse: ; Next Hsym
add.w #SYM_ENTRY.sizeof,d0
move.l d0,SYMFIND_HSYM ;Save the HSYM (FIXME?)
bsr DerefSym_Reg ; a0 -> SYM_ENTRY of the file / a1 -> Folder
move.l a0,d0
beq.s \EndOfFolder
rts