Source/ Codesnippets | | | | | fgc,fpc, nFGC, nFPC, nFPCaA, nFileExists, nDirectoryExists, nFileSize, nFGCFromTo KompilierenMarqueSéparation
nProc fGetAppDataPath{
long m=dim(MAX_PATH)
long l=shgetspecialfolderpath(,m,CSIDL_APPDATA,)
ifnot l {
dispose(m)
return "C:\\temp\\"
}
string s=string$(m,0)
dispose(m)
return s+"\\"
}
nProc nFileExists(string fle){
long hFile=createFile(fle,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
case hFile==INVALID_HANDLE_VALUE : return false
closeHandle(hFile)
return true
}
nProc nDirectoryExists(string fle){
long hFile=createFile(fle,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,0)
case hFile==INVALID_HANDLE_VALUE : return false
closeHandle(hFile)
return true
}
nProc nFileSize(string fle){
long hFile=createFile(fle,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
case hFile==INVALID_HANDLE_VALUE : return -1
long sz=getFileSize(hFile,0)
closeHandle(hFile)
return sz
}
nProc fgc(string s){
long hFile=createFile(s,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
case hFile==INVALID_HANDLE_VALUE : return ""
long sz=dim(16)
ifnot getFileSizeEx(hFile,sz) {
dispose(sz)
closeHandle(hFile)
return ""
}
long fz=long(sz,0)
if long(sz,4) or fz==0 {//0 byte or bigger than 2GB not supported
dispose(sz)
closeHandle(hFile)
return ""
}
dispose(sz)
long data=dim(fz),rdC=dim(4)
readFile(hFile,data,fz,rdC,0)
long rdd=long(rdC,0)
dispose(rdC)
closeHandle(hFile)
s=""
case rdd : s=char$(data,0,rdd)
dispose(data)
return s
}
nProc fpc(string s,dta){
long hFile=createFile(s,GENERIC_WRITE,0,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0)
case hFile==INVALID_HANDLE_VALUE or hFile==0 : return 0
long wtC=dim(4),kk
writeFile(hFile,dta,len(dta),wtC,0)
flushFileBuffers(hFile)
closeHandle(hFile)
case len(dta)==long(wtC,0) : kk=1
dispose(wtC)
return kk
}
nProc fpca(string s,dta){
casenot nFileExists(s) : return fpc(s,dta)
long hFile=createFile(s,4,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
case hFile==INVALID_HANDLE_VALUE or hFile==0 : return 0
long wtC=dim(4),kk
writeFile(hFile,dta,len(dta),wtC,0)
flushFileBuffers(hFile)
closeHandle(hFile)
case len(dta)==long(wtC,0) : kk=1
dispose(wtC)
return kk
}
nProc nfgcfrom(string s,long from){
long hFile=createFile(s,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
case hFile==INVALID_HANDLE_VALUE : return ""
long sz=dim(16)
ifnot getFileSizeEx(hFile,sz) {
dispose(sz)
closeHandle(hFile)
return ""
}
long fz=long(sz,0)
if long(sz,4) or fz==0 or fz<=from {//0 byte or bigger than 2GB not supported
dispose(sz)
closeHandle(hFile)
return ""
}
dispose(sz)
long data=dim(fz-from),rdC=dim(4)
setFilePointer(hFile,from,,)
readFile(hFile,data,fz-from,rdC,0)
long rdd=long(rdC,0)
dispose(rdC)
closeHandle(hFile)
s=""
case rdd : s=char$(data,0,rdd)
dispose(data)
return s
}
nProc nfgcfromto(string s,long from,bCount){
long hFile=createFile(s,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0)
case hFile==INVALID_HANDLE_VALUE : return ""
long sz=dim(16)
ifnot getFileSizeEx(hFile,sz) {
dispose(sz)
closeHandle(hFile)
return ""
}
long fz=long(sz,0)
if long(sz,4) or fz==0 or fz<=from {//0 byte or bigger than 2GB not supported
dispose(sz)
closeHandle(hFile)
return ""
}
dispose(sz)
case bCount==-1 : bCount=fz-from
long data=dim(bCount),rdC=dim(4)
setFilePointer(hFile,from,,)
readFile(hFile,data,bCount,rdC,0)
long rdd=long(rdC,0)
dispose(rdC)
closeHandle(hFile)
s=""
case rdd : s=char$(data,0,rdd)
dispose(data2>)
return s
}
Varianten comme Procs (sans n): [...] |
| | | | |
|
Zum QuelltextOptions du sujet | 3.559 Views |
Themeninformationencet Thema hat 1 participant: |
|