Last active
January 3, 2022 15:51
-
-
Save CarlTBarnes/e2b1f07fcc306192c32995c03249d28b to your computer and use it in GitHub Desktop.
Path Exists or File Exists functions versus Clarion Exists()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!Clarion Exists() returns True whethere File or Directory. These functions will check explicitly for File or Path. | |
MAP | |
FileExists(STRING FileName,<*LONG OutAttributes>),BOOL !Return 1 if FileName exists and is File not Directory | |
PathExists(STRING PathName,<*LONG OutAttributes>),BOOL !Return 1 if PathName exists and is Directory not File | |
ExistsFileOrPath(STRING FileOrPathName,<*LONG OutAttributes>),BYTE !Return 1=File 2=Path 0=N/A | |
MODULE('Win32') | |
GetFileAttributes(*CSTRING FileName),LONG,PASCAL,RAW,DLL(1),NAME('GetFileAttributesA') | |
END | |
END | |
!--------------------------------------------------------------------------- | |
FileExists PROCEDURE(STRING FN, <*LONG OutAttr>)!,BOOL !1=File | |
cName CSTRING(261),AUTO | |
Attr LONG,AUTO | |
!_INVALID_FILE_ATTRIBUTES EQUATE(-1) !If function fails it returns INVALID_FILE_ATTRIBUTES. Call GetLastError() for error information, | |
!_FILE_ATTRIBUTE_DIRECTORY EQUATE(10h) !The handle that identifies a directory | |
CODE | |
cName=CLIP(FN) | |
Attr = GetFileAttributes(cName) | |
IF ~OMITTED(OutAttr) THEN OutAttr=Attr. | |
RETURN CHOOSE(Attr <> -1 AND ~BAND(Attr,10h)) | |
!--------------------------------------------------------------------------- | |
PathExists PROCEDURE(STRING FN, <*LONG OutAttr>)!,BOOL !1=Path | |
cName CSTRING(261),AUTO | |
Attr LONG,AUTO | |
!_INVALID_FILE_ATTRIBUTES EQUATE(-1) !If function fails it returns INVALID_FILE_ATTRIBUTES. Call GetLastError() for error information, | |
!_FILE_ATTRIBUTE_DIRECTORY EQUATE(10h) !The handle that identifies a directory | |
CODE | |
cName=CLIP(FN) | |
Attr = GetFileAttributes(cName) | |
IF ~OMITTED(OutAttr) THEN OutAttr=Attr. | |
RETURN CHOOSE(Attr <> -1 AND BAND(Attr,10h)) | |
!--------------------------------------------------------------------------- | |
ExistsFileOrPath PROCEDURE(STRING FN, <*LONG OutAttr>)!,BYTE !1=File 2=Path | |
cName CSTRING(261),AUTO | |
Attr LONG,AUTO | |
ForP12 BYTE | |
!_INVALID_FILE_ATTRIBUTES EQUATE(-1) !If function fails it returns INVALID_FILE_ATTRIBUTES. Call GetLastError() for error information, | |
!_FILE_ATTRIBUTE_DIRECTORY EQUATE(10h) !The handle that identifies a directory | |
CODE | |
cName=CLIP(FN) | |
Attr = GetFileAttributes(cName) | |
IF ~OMITTED(OutAttr) THEN OutAttr=Attr. | |
IF Attr <> -1 THEN ForP12=CHOOSE(~BAND(Attr,10h),1,2). | |
RETURN ForP12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment