(FILECREATED "25-Jul-85 22:38:51" {ERIS}<LISP>INTERMEZZO>PATCHES>DORADODIRPATCH.;1 4310 changes to: (VARS DORADODIRPATCHCOMS) (FNS \M44GENERATENEXT)) (PRETTYCOMPRINT DORADODIRPATCHCOMS) (RPAQQ DORADODIRPATCHCOMS ((FNS \M44GENERATENEXT))) (DEFINEQ (\M44GENERATENEXT [LAMBDA (DIRSTREAM SEARCHSTATE FILTER DESIREDVERSION HOSTPREFIX PATTERNLENGTH GENFILESTATE) (* edited: "25-Jul-85 22:37") (* * Produces the next filename from directory DIRSTREAM satisfying SEARCHSTATE and the more constrained FILTER and DESIREDVERSION, or returns NIL if no more files. HOSTPREFIX is string to put on front, or NIL for names only. PATTERNLENGTH is the length of the pattern in SEARCHSTATE. GENFILESTATE is a a M44GENFILESTATE whose GENSTREAM and ENTRYSTART want to be set appropriately for \M44FILEINFOFN; if NIL, then the value is returned for SORTFILES in the form (name version entrystart)) (PROG ((SAWDOT (MEMB (CHARCODE %.) (fetch CHARLIST of SEARCHSTATE))) ENTRYSTART TEMP PREFIXLEN TOTALLEN THISVERSION RESULT INDEX) LP (RETURN (COND ((SETQ TEMP (\SEARCHDIR1 DIRSTREAM SEARCHSTATE)) (SETQ ENTRYSTART (IDIFFERENCE (GETFILEPTR DIRSTREAM) (IPLUS PATTERNLENGTH 13))) (* Read all the characters from the directory) (SETQ TOTALLEN (IPLUS PATTERNLENGTH (SUB1 TEMP))) (for I from (SUB1 TEMP) to 1 by -1 do (* The SUB1 is because the last character is the undesired dot) (SELCHARQ (\BIN DIRSTREAM) [! (RETURN (SETQ THISVERSION (\M44READVERSION DIRSTREAM (SUB1 I] (%. (SETQ SAWDOT T)) NIL) finally (SETQ THISVERSION 1)) (COND ((AND DESIREDVERSION (NEQ THISVERSION DESIREDVERSION)) (* Failure, try next) (GO LP))) [SETQ RESULT (ALLOCSTRING (IPLUS TOTALLEN (SETQ PREFIXLEN (COND (HOSTPREFIX (NCHARS HOSTPREFIX)) (T 0))) (COND ((AND (EQ THISVERSION 1) HOSTPREFIX) 2) (T 0)) (COND (SAWDOT 0) (T 1] (AND HOSTPREFIX (RPLSTRING RESULT 1 HOSTPREFIX)) (\SETFILEPTR DIRSTREAM (IPLUS ENTRYSTART 13)) (* Now read the whole name) (SETQ INDEX PREFIXLEN) (for I from TOTALLEN to 1 by -1 do (SELCHARQ (SETQ TEMP (\BIN DIRSTREAM)) (%. (SETQ SAWDOT T)) (! [OR SAWDOT (\RPLCHARCODE RESULT (add INDEX 1) (SETQ SAWDOT (CHARCODE %.] [COND (HOSTPREFIX (\RPLCHARCODE RESULT (add INDEX 1) (CHARCODE ;)) (to (SUB1 I) do (\RPLCHARCODE RESULT (add INDEX 1) (COND (GENFILESTATE (\BIN DIRSTREAM)) (T (* Make everything look like version 1 for benefit of SORT. Will replace with real thing later) (CHARCODE 1] (RETURN)) NIL) (\RPLCHARCODE RESULT (add INDEX 1) TEMP)) (OR SAWDOT (\RPLCHARCODE RESULT (add INDEX 1) (CHARCODE %.))) (COND ((AND (EQ THISVERSION 1) HOSTPREFIX) (RPLSTRING RESULT (ADD1 INDEX) ";1"))) (COND ((AND FILTER (NOT (DIRECTORY.MATCH FILTER RESULT))) (GO LP))) (COND (GENFILESTATE (replace ENTRYSTART of GENFILESTATE with ENTRYSTART) (replace DIRINFO of (fetch GENSTREAM of GENFILESTATE) with NIL) RESULT) (T (LIST RESULT THISVERSION ENTRYSTART]) ) (DECLARE: DONTCOPY (FILEMAP (NIL (267 4288 (\M44GENERATENEXT 277 . 4286))))) STOP