English
Source / code snippets

Fgcfpc Ndirectoryexists Nfgc Nfgcfrom Nfileexists Nfilesize Nfpc Nfpcaa

 
fgc,fpc, nFGC, nFPC, nFPCaA, nFileExists, nDirectoryExists, nFileSize, nFGCFromTo
CompileMarkSeparation
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

}


mutants as Procs (without n):  [...] 
 
06/23/11  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

3.558 Views

Untitledvor 0 min.
iF12/29/15
RudiB.11/08/12
Jörg Sellmeyer04/06/12
Dieter Zornow04/05/12
More...

Themeninformationen

this Topic has 1 subscriber:

iF (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie