Page 1 of 1

[CreateDirectory]Return error code for failure.

Posted: Mon Mar 26, 2018 3:02 pm
by skywalk
Because FileSize() returns false positives if rejected characters in pathname,
it falls back to CreateDirectory() or api call to SHCreateDirectory_() to know for certain if a path exists?
Or since FileSize() returns codes, maybe a new error code can be created?

EDIT: PathFileExists_(Fpathname$) does not return false positives if wildcard characters in Fpathname$.

Re: [CreateDirectory]Return error code for failure.

Posted: Mon Mar 26, 2018 3:31 pm
by Marc56us
Another (secure) way, check filename before check size or exist

CheckFilename()
Returns nonzero if the filename does not contain invalid characters and zero if it does.

Code: Select all

Debug CheckFilename("c:\try3\z|z")             
Debug CheckFilename("c:\try3\z:z")             
Debug CheckFilename("c:\try3\z"+#DQUOTE$+"z")  
Debug CheckFilename("c:\try3\z<z")             
Debug CheckFilename("c:\try3\z>z")             
Debug CheckFilename("c:\try3\z*z")             
Debug CheckFilename("c:\try3\z?z")     

Code: Select all

0
0
0
0
0
0
0
= bad filename for all

But you're right, actually, it would be nice if FileSize automatically tests if the file name is valid before continuing.

:wink: