$IFNDEF WIN32
SHOWMESSAGE "Umm, you can't use fileAttribs.inc on platforms other than Windows 9x.": END
$ENDIF
$IFNDEF __FILEATTRIBS_INC: $DEFINE __FILEATTRIBS_INC
$IFNDEF __RQINC
CONST faReadOnly = 1
CONST faHidden = 2
CONST faSysFile = 4
CONST faVolumeID = 8
CONST faDirectory = 16
CONST faArchive = 32
CONST faAnyFile = 63
CONST faNormal = 128
CONST faTmpFile = 256
CONST faCompressed = 2048
$ENDIF
DECLARE FUNCTION ChMod LIB "kernel32" ALIAS "SetFileAttributesA" _
(lpFileName AS STRING, dwFileAttributes AS DWORD) AS LONG
DECLARE FUNCTION GetMod LIB "kernel32" ALIAS "GetFileAttributesA" _
(lpFileName AS STRING) AS LONG
DECLARE FUNCTIONI CanAccess(...) AS LONG
DECLARE FUNCTION RstMod(lpFileName AS STRING) AS LONG
DIM CanAccess.ENOFILE AS LONG
FUNCTIONI CanAccess(...) AS LONG: CanAccess.ENOFILE=0
DIM lpFileName AS STRING, dwFileAttributes AS DWORD
lpFileName=PARAMSTR$(1): dwFileAttributes=PARAMVAL(1)
IF dwFileAttributes=0 THEN dwFileAttributes=faNormal
IF GetMod(lpFileName)=dwFileAttributes THEN
Result=1
ELSE
IF FILEEXISTS(lpFileName)=0 THEN
CanAccess.ENOFILE=1: Result=0
ELSE
Result=0
END IF
END IF
END FUNCTIONI
DIM RstMod.ENOFILE AS LONG
FUNCTION RstMod(lpFileName AS STRING) AS LONG: RstMod.ENOFILE=0
IF FILEEXISTS(lpFileName)=0 THEN
Result=0: RstMod.ENOFILE=1
ELSE
IF ChMod(lpFileName, faNormal)=0 THEN
Result=0
ELSE
Result=1
END IF
END IF
END FUNCTION
$ENDIF
|