SHARE
TWEET

FCount.e

Yesideez May 9th, 2019 (edited) 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* $VER: FCount.e v1.00 by Zeb/SLP (09-May-2019) */
  2.  
  3. OPT OSVERSION=37
  4.  
  5. ENUM ARG_DIR,ARG_PATTERN,ARG_DIRS,ARG_FILES,NUMARGS
  6.  
  7. MODULE 'dos/dos'
  8.  
  9. DEF dir,dirw[100]:STRING,patw[100]:STRING,dirmode=FALSE,filemode=FALSE,
  10.     rdargs=NIL,args[NUMARGS]:LIST,x,templ,lock,fib:fileinfoblock,rc=0,
  11.     pattern[256]:STRING,er,pat,found=0
  12.  
  13. PROC main()
  14.   FOR x:=0 TO NUMARGS-1 DO args[x]:=0
  15.   templ:='DIR,PATTERN,DIRS/S,FILES/S'
  16.   IF (rdargs:=ReadArgs(templ,args,NIL))
  17.     IF args[ARG_DIRS] THEN dirmode:=TRUE
  18.     IF args[ARG_FILES] THEN filemode:=TRUE
  19.     IF (dirmode=FALSE) AND (filemode=FALSE) THEN filemode:=TRUE
  20.     dir:=args[ARG_DIR]
  21.     pat:=args[ARG_PATTERN]
  22.     IF (dir=FALSE) OR (pat=FALSE)
  23.       WriteF('ERROR: required arguments missing\n');
  24.       rc:=20;
  25.     ELSE
  26.       StrCopy(dirw,dir,ALL)
  27.       StrCopy(patw,pat,ALL)
  28.       ParsePatternNoCase(patw,pattern,256)
  29.       IF (lock:=Lock(dirw,ACCESS_READ))
  30.         Examine(lock,fib)
  31.         WHILE (ExNext(lock,fib))
  32.           IF MatchPatternNoCase(pattern,fib.filename)
  33.             IF (fib.direntrytype>0) AND dirmode THEN INC found
  34.             IF (fib.direntrytype<0) AND filemode THEN INC found
  35.           ENDIF
  36.         ENDWHILE
  37.         UnLock(lock)
  38.         WriteF('\d\n',found)
  39.         IF (found>0) THEN rc:=5
  40.       ENDIF
  41.     ENDIF
  42.     FreeArgs(rdargs)
  43.   ENDIF
  44. ENDPROC rc
  45.  
  46. -> $VER: FCount.e v1.00 by Zeb/SLP (09-May-2019)
  47. CHAR '$VER: FCount v1.00 by Zeb/SLP (09-May-2019)\0'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top