CheckFullFilename()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

CheckFullFilename()

Post by c4s »

We have CheckFilename() for the name of the file but what about something like CheckPath() (with optional parameter for checking the hard disk letter or not) that validates the path and CheckFullFilename() that checks the complete filename for not allowed characters.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: CheckFullFilename()

Post by cas »

It is easy to make one by yourself by combining FindString(), StringField() and CheckFilename().
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: CheckFullFilename()

Post by skywalk »

Or a FileSize() Macro... :idea:

Code: Select all

Macro FileExists(Fname)
  ;  0 = File or Folder does not exist
  ;  1 = File Exists
  ; -1 = Folder Exists
  ; Since FileSize() returns:
  ;       -1 = File Not found.
  ;       -2 = File is a directory.
  ;        0 = Empty File, > 1 = File Exists
  ;        FileSize() respects '*' wildcards and reports results accordingly.
  FileSize(Fname) + 1
EndMacro  

Define.i fn
CreateDirectory("c:\z~z\")
fn=CreateFile(0,"c:\z~z\1.txt"): CloseFile(0)
fn=CreateFile(0,"c:\z~z\2.txt"): CloseFile(0)

Debug " - File(s) or Folder Exists? - "
Debug FileExists("c:\zz~z\")      ;  0 = Not a Folder 
Debug FileExists("c:\z~z\*.*")    ; -1 = Valid Folder
Debug FileExists("c:\z~z\*.txt")  ;  1 = Valid File(s)
Debug FileExists("c:\z~z\1.txt")  ;  1 = Valid File
Debug FileExists("c:\z~z\3.txt")  ;  0 = Not a File
Debug FileExists("c:\z~z\*.csv")  ;  0 = File(s) Not Found
Debug FileExists("c:\z~z\?,3")    ;  0 = File Not Found
;DeleteDirectory("c:\z~z\", "*.*", #PB_FileSystem_Recursive)
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply