# HG changeset patch # User boisy # Date 1106308779 0 # Node ID 3beb3d140cb5651c56517201225924d046de9fb1 # Parent 80cdc57fbaaefed7c79ce5123c32ec7a3948c644 Curtis Boyle's updated dir... diff -r 80cdc57fbaae -r 3beb3d140cb5 level1/cmds/dir_cb.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level1/cmds/dir_cb.asm Fri Jan 21 11:59:39 2005 +0000 @@ -0,0 +1,761 @@ +* DIR Edition #8 - Released Mar. 12/2000 +* Added the '-c' option, which stands for case insensitive. This means that +* wildcard filename matches do not care as to whether the filenames are +* upper or lowercase, when compared to the wildcard filename search you +* specified. There still are some quirks to using the '*' wildcard in some +* cases... I am still tracking down why that is happening. +* +* DIR Edition #7 - Released Jan. 16/2000 +* +* This is a new version of the DIR command, based on the version Alan Dekok +* did with wildcarding. It fixes the year to work with modern clock drivers, +* allowing from 1900-2155. It also fixes the help message, and changes the +* edition # to 7. It should work with all version of OS9/NitrOS9/PowerBoost. +* +* -Curtis- +* +* Edition #7: (L. Curtis Boyle) +* 2000/01/15: Fixed help message bug. +* 2000/01/16: Fixed year output to handle 1900-2155 +* +* Edition #8 (Curtis) +* 2000/03/11 Fixed Bad Filename error +* 2000/03/12 Added -c option (case insensitive filematching) + +* Need to do 1 things: +* Fix '*' wildcards (ex. DIR *.lzh returns completely different than +* DIR *lzh - 1st only does files with ONE '.' char, 2nd does mix of ONE +* and >1, but not all the same as first example???) + + nam dir + ttl program module + +* Disassembled 94/11/18 12:51:39 by Alan DeKok + + ifp1 + use defsfile + endc + +tylg set Prgrm+Objct +atrv set ReEnt+rev +rev set $01 + mod eom,name,tylg,atrv,start,size + +u0000 rmb 1 Path to current Directory +u0001 rmb 1 Path to RAW drive (current data or exec dir's drive) +u0002 rmb 2 Pointer to directory we are DIRing +u0004 rmb 2 Ptr to end of current sub-parm (if more than 1) +u0006 rmb 2 Pointer to filename match string we are DIRing +u0008 rmb 1 Case insensitive flag (0=NO) +u0009 rmb 1 Wildcard matched flag (0=NO) +u000A rmb 1 0=Filename not written yet, <>0 means is written out +u000B rmb 1 Merge of directories/non-directories/ext. info flags +u000C rmb 1 Wildcards in effect flag +u000D rmb 1 Extended info flag (0=No) +u000E rmb 1 Directories ONLY (0=No) +u000F rmb 1 Non-directories ONLY (0=NO) +u0010 rmb 1 One entry/line flag (0=Yes, else no) +u0011 rmb 1 Screen width +u0012 rmb 1 # chars left on current output line +u0013 rmb 2 Length of current filename +u0015 rmb 1 char from current directory entry +u0016 rmb 1 char from wild card string +u0017 rmb 1 Attributes for DIR open (Ex. EXEC) +* File descriptor info - 1st 13 bytes - only used if certain options and/or +* extended directory listings are requested. +u0018 rmb 1 File attributes +u0019 rmb 2 File owner ID +u001B rmb 5 Date last modified +u0020 rmb 1 DIR path # (link count on FD read, but not used) +u0021 rmb 4 File size (in bytes) +* Start of WritLn buffer for each directory entry starts here +u0025 rmb 1 +* Information to be printed out goes here +* user-number, 4 bytes of hex, space space +u0026 rmb 6 +* YY/MM/DD HHMM +u002C rmb 17 +* file attributes +u003B rmb 10 +* starting sector number +u0045 rmb 8 +* file size +u004D rmb 8 +* a space +u0055 rmb 1 +* file name +u0056 rmb 25 +u006F rmb 1 +u0070 rmb 4 +* starting sector of the file (3 bytes) +u0074 rmb 2 +u0076 rmb 1 +u0077 rmb 1 always 0 +AllFlag rmb 1 $2E=don't print out .foo, $00=print out .foo + rmb 256 leave room for the stack +size equ . + +name fcs /dir/ + fcb $08 + +start ldd #$0150 Default to multiple entries/line, 80 column width + std L0449,pc point to '.' + sty =80 characters/line? + bhs L00AF Yes, continue + lda #60 go to 64 + cmpb #60 64 to 79 chars? + bhs L00AD Yes, set width to 64 + lda #48 48 to 63 chars? + cmpb #48 Yes, set width to 48 + bhs L00AD + lda #32 32 to 47 chars? + cmpb #32 Yes, set to 32 chars + bhs L00AD + clr L044B,pc point to '@' + os9 I$Open Open current drive RAW (to get file descriptors) + lbcs L0430 Error, check for EOF, or exit with it + sta L044D,pc Print ' Directory of ' to screen + ldy #$000F + lda #$01 + os9 I$Write + lbcs L0430 + leay L045C,pc Write out extended info header lines + lbsr L0627 + lbcs L0430 + +* Main dir entry reading loop +L0145 lda 0, and AllFlag may be zero (=print out all files) + anda #$7F + cmpa 16 chars, bump to next 'tab' stop + negb # spaces we have to print to pad to next 'tab' + sta L04F2,pc Write spaces out + os9 I$Write + lbcs L0430 + lbra L0145 On to next filename entry + +* Flush out current output line to screen, reset # chars left on output line +* to screen width. +L0205 lda #$01 Print CR by itself + ldy #$0001 + leax >L044A,pc + os9 I$WritLn + lbcs L0430 + lda L0505,pc Point to help message + lbsr L0627 Print it out + lbra L0430 + +L026C addb #EXEC. add in exec attribute + bra L023A and get another character + +L0270 clr L0449,pc point to a '.' (current dir) + stx 1, match +L0324 lda ,x Get char from current dir entry filename + + bsr ForcUppr Change case if needed + + ldb ,y Get char from user match filename + std 0 +ForcUppr tst L04D4,pc Point to default date/attributes string + leay L044A,pcr output a CR + lda #$01 + ldy #$0001 + os9 I$WritLn and then exit +L0446 os9 F$Exit + +L0449 fcc /./ +L044A fcb $0d +L044B fcc /@/ + fcb $0d +L044D fcb $0a + fcc / Directory of / +L045C fcb $0a + fcc /User # Last Modified Attributes Sector File Size File Name/ + fcb $0d + fcc /------ --------------- ---------- ------ --------- ----------/ + fcb $0d +L04D4 fcc ' 0000/00/00 0000 dsewrewr' +L04F2 fcc / / +L0505 fcb $0a + fcc 'dir [-opts] [path/patt] [-opts]' + fcb $0d + fcc /opts: x - use current exec dir/ + fcb $0d + fcc ' s - one entry/line' + fcb $0d + fcc ' e/l - extended directory' + fcb $0d + fcc / a - show '.files', too/ + fcb $0d + fcc / d - only directory files/ + fcb $0d + fcc / f - only non-dir files/ + fcb $0d + fcc / c - case insensitive filename match (BUT NOT DIR NAME)/ + fcb $0d + fcc / ? - help message/ + fcb $0d + fcc /pattern: may include wild cards/ + fcb $0d + fcc / * - multiple character/ + fcb $0d + fcc / ? - single character/ + fcb $0d + +* Print several lines of text up to 80 chars each +* Entry: X=Ptr to multi-line text string (CR terminates lines) +* B=# of lines to write. +L0627 decb Dec line counter + ldy #80 + os9 I$WritLn + bcs L0642 Error writing, return with it + pshs d preserve path/line count + tfr y,d Move size actually written to D + leax d,x Bump source buffer ptr to next line + puls d Restore path/line count + tstb Any lines left to print? + beq L0642 No, exit + bra L0627 Yes, print next line + +L0642 rts + + emod +eom equ *