ISFILE now (in 9.02) only supports files and not directories.
Now I need ISFILEORDIR. Or did I miss something?
Now I need ISFILEORDIR. Or did I miss something?
DIR$ (spec, [b]ONLY[/b] %SUBDIR) 'dirs only DIR$ (spec, %SUBDIR) 'dirs and files DIR$ (spec) ' files only
#COMPILE EXE #DIM ALL FUNCTION PBMAIN () AS LONG DIM temp$,msg$ temp$ = DIR$("C:\WINDOWS\*.",ONLY %SUBDIR OR %SYSTEM OR %HIDDEN) WHILE LEN(temp$) 'omit XP $...Uninstall.... directories for listing IF LEFT$(temp$,1) <> "$" THEN msg$ = BUILD$(msg$,$CRLF,temp$) temp$ = DIR$(NEXT) WEND ? msg$ END FUNCTION
MACRO FUNCTION IsDirectory(Dirname) MACROTEMP result DIM result AS LONG IF DIR$(Dirname, ONLY %SUBDIR OR %SYSTEM OR %HIDDEN) <> "" THEN result = -1 IF INSTR(Dirname,ANY "*?") THEN result = 0 'no wildcards like IsFile operation END MACRO = result
MACRO FUNCTION IsDirectory(Dirname) MACROTEMP result DIM result AS LONG IF DIR$(Dirname, ONLY %SUBDIR OR %SYSTEM OR %HIDDEN) <> "" THEN result = -1 IF INSTR(Dirname,ANY "*?") THEN result = 0 'no wildcards like IsFile operation END MACRO = result
ONLY %SUBDIR OR %SYSTEM OR %HIDDEN
' Equate patterns: ' alpha: ONLY %SUBDIR ' beta: ONLY %SUBDIR OR %SYSTEM OR %HIDDEN ' Equate Attributes Example Result Expected ' ------ ---------- ------- ------ -------- ' alpha Dir C:\Windows T yes ' alpha Dir, Hidden C:\Windows\Installer F yes ' alpha File C:\WINDOWS\winhlp32.exe F yes ' alpha File, Hidden C:\WINDOWS\winnt.bmp F yes ' beta Dir C:\Windows T yes ' beta Dir, Hidden C:\Windows\Installer T yes ' beta File C:\WINDOWS\winhlp32.exe F yes ' beta File, Hidden C:\WINDOWS\winnt.bmp T no
#If Not %def(%TRUE) ' win32api.inc not included %TRUE = -1 #EndIf Function IsDirectory(rsPath As String) As Long ' Purpose: test if a directory exists (not a volume) ' Parameters: rsPath - directory name to test. invalid if empty or has wildcards. works with or without a trailing slash ' Returns: T: directory exists; F: otherwise ' Note: "Only %SUBDIR Or %SYSTEM Or %HIDDEN" will return T for a hidden or system file Local lRtn As Long If (Len(rsPath) > 0) And (IsFalse InStr(rsPath, Any "*?")) Then If Len(Dir$(rsPath, Only %SUBDIR)) > 0 Then ' directory, not hidden or system lRtn = %TRUE Else ' test for hidden or system directory If IsFalse IsFile(rsPath) Then ' not a file If Len(Dir$(rsPath, Only %SUBDIR Or %SYSTEM Or %HIDDEN)) > 0 Then ' directory, hidden or system lRtn = %TRUE End If End If End If End If 'IsDirectory_Exit: Function = lRtn End Function
#COMPILE EXE #DIM ALL FUNCTION PBMAIN () AS LONG IF ISFILE ("myFile_V5.dat") THEN ? "Found the file" ELSE ? "Failed" END IF END FUNCTION
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment