Ignore:
Timestamp:
Feb 24, 2002, 3:47:28 AM (24 years ago)
Author:
bird
Message:

New kFile* classes; now in sync with os2tools.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/common/kFile.cpp

    r7093 r8003  
    1 /* $Id: kFile.cpp,v 1.9 2001-10-17 14:21:10 bird Exp $
     1/* $Id: kFile.cpp,v 1.10 2002-02-24 02:47:24 bird Exp $
    22 *
    33 * kFile - Simple (for the time being) file class.
     
    2727#include <stdlib.h>
    2828
     29#include "kTypes.h"
     30#include "kError.h"
    2931#include "kFile.h"
    3032
     
    4345 * @remark
    4446 */
    45 BOOL    kFile::refreshFileStatus()
     47KBOOL   kFile::refreshFileStatus()
    4648{
    4749    if (fStdDev)
     
    5052    if (!fStatusClean)
    5153    {
    52         rc = DosQueryFileInfo(hFile, FIL_QUERYEASIZE, &filestatus, sizeof(filestatus));
     54        rc = DosQueryFileInfo(OSData.os2.hFile, FIL_QUERYEASIZE, &OSData.os2.filestatus, sizeof(OSData.os2.filestatus));
    5355        fStatusClean = (rc == NO_ERROR);
    5456        if (!fStatusClean && fThrowErrors)
    55             throw ((int)rc);
     57            throw (kError(rc));
    5658    }
    5759    else
     
    6668 * @returns     Success indicator.
    6769 */
    68 BOOL    kFile::position()
     70KBOOL   kFile::position()
    6971{
    7072    /*
     
    7577    {
    7678        ULONG   off;
    77         rc = DosSetFilePtr(hFile, offVirtual, FILE_BEGIN, &off);
     79        rc = DosSetFilePtr(OSData.os2.hFile, offVirtual, FILE_BEGIN, &off);
    7880        if (rc != NO_ERROR || off != offVirtual)
    7981        {
    8082            if (fThrowErrors)
    81                 throw ((int)rc);
     83                throw (kError(rc));
    8284            return FALSE;
    8385        }
     
    99101 * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    100102 */
    101 BOOL kFile::bufferRead(ULONG offFile) throw (int)
     103KBOOL kFile::bufferRead(unsigned long offFile) throw(kError)
    102104{
    103105    ULONG   cbRead;
     
    108110
    109111    /* check that the request is valid */
    110     if (offFile > filestatus.cbFile)
     112    if (offFile > OSData.os2.filestatus.cbFile)
    111113        return FALSE;
    112114
     
    123125
    124126    /* If readonly file optimize end of file */
    125     if (fReadOnly && cbBuffer + offFile > filestatus.cbFile)
    126         offFile = filestatus.cbFile > cbBuffer ? filestatus.cbFile - cbBuffer : 0UL;
     127    if (fReadOnly && cbBuffer + offFile > OSData.os2.filestatus.cbFile)
     128        offFile = OSData.os2.filestatus.cbFile > cbBuffer ? OSData.os2.filestatus.cbFile - cbBuffer : 0UL;
    127129
    128130    /* need to change file ptr? */
     
    130132    {
    131133        ULONG ul;
    132         rc = DosSetFilePtr(hFile, offFile, FILE_BEGIN, &ul);
     134        rc = DosSetFilePtr(OSData.os2.hFile, offFile, FILE_BEGIN, &ul);
    133135        if (rc != NO_ERROR)
    134136        {
    135137            if (fThrowErrors)
    136                 throw ((int)rc);
     138                throw (kError(rc));
    137139            return FALSE;
    138140        }
     
    141143
    142144    /* read from the file */
    143     cbRead = min(filestatus.cbFile - offFile, cbBuffer);
    144     rc = DosRead(hFile, pachBuffer, cbRead, &cbRead);
     145    cbRead = KMIN(OSData.os2.filestatus.cbFile - offFile, cbBuffer);
     146    rc = DosRead(OSData.os2.hFile, pachBuffer, cbRead, &cbRead);
    145147    if (rc == NO_ERROR)
    146148    {
     
    156158        fBufferDirty    = FALSE;
    157159        if (fThrowErrors)
    158             throw ((int)rc);
     160            throw (kError(rc));
    159161        return FALSE;
    160162    }
     
    169171 * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    170172 */
    171 BOOL kFile::bufferCommit(void) throw (int)
     173KBOOL kFile::bufferCommit(void) throw(kError)
    172174{
    173175    ULONG   cbWrote;
     
    181183    if (offBuffer != offReal)
    182184    {
    183         rc = DosSetFilePtr(hFile, offBuffer, FILE_BEGIN, &ul);
     185        rc = DosSetFilePtr(OSData.os2.hFile, offBuffer, FILE_BEGIN, &ul);
    184186        if (rc != NO_ERROR)
    185187        {
    186188            if (fThrowErrors)
    187                 throw ((int)rc);
     189                throw (kError(rc));
    188190            return FALSE;
    189191        }
     
    192194
    193195    /* write to the file */
    194     rc = DosWrite(hFile, pachBuffer, cbBufferValid, &cbWrote);
     196    rc = DosWrite(OSData.os2.hFile, pachBuffer, cbBufferValid, &cbWrote);
    195197    fStatusClean = FALSE;
    196198    if (rc == NO_ERROR)
     
    201203    else
    202204    {
    203         DosSetFilePtr(hFile, offReal, FILE_BEGIN, &ul);
     205        DosSetFilePtr(OSData.os2.hFile, offReal, FILE_BEGIN, &ul);
    204206        if (fThrowErrors)
    205             throw ((int)rc);
     207            throw (kError(rc));
    206208        return FALSE;
    207209    }
     
    222224 * @author      knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    223225 */
    224 kFile::kFile(HFILE hFile, BOOL fReadOnly)
     226kFile::kFile(HFILE hFile, KBOOL fReadOnly)
    225227:   fReadOnly(fReadOnly),
    226228    fStatusClean(FALSE),
     
    229231    offReal(0),
    230232    pszFilename(NULL),
    231     hFile(hFile),
    232233    fStdDev(TRUE),
    233234    pachBuffer(NULL),
     
    236237    fBufferDirty(FALSE)
    237238{
     239    OSData.os2.hFile = hFile;
    238240    if (!refreshFileStatus())
    239         throw ((int)rc);
     241        throw (kError(rc));
    240242    this->pszFilename = strdup("");
    241243}
     
    252254 * @author      knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    253255 */
    254 kFile::kFile(const char *pszFilename, BOOL fReadOnly/*=TRUE*/)
     256kFile::kFile(const char *pszFilename, KBOOL fReadOnly/*=TRUE*/)
    255257:   fReadOnly(fReadOnly),
    256258    fStatusClean(FALSE),
     
    283285    }
    284286
    285     rc = DosOpen((PCSZ)pszFilename, &hFile, &ulAction, 0, FILE_NORMAL,
     287    rc = DosOpen((PCSZ)pszFilename, &OSData.os2.hFile, &ulAction, 0, FILE_NORMAL,
    286288                 fulOpenFlags, fulOpenMode, NULL);
    287289    if (rc != NO_ERROR)
    288         throw ((int)rc);
     290        throw (kError(rc));
    289291
    290292    if (!refreshFileStatus())
    291         throw ((int)rc);
     293        throw (kError(rc));
    292294
    293295    char szFullName[CCHMAXPATH];
     
    299301
    300302    /* Buffering */
    301     cbBuffer   = (fReadOnly && filestatus.cbFile < 32768) ? filestatus.cbFile : 8192;
     303    cbBuffer   = (fReadOnly && OSData.os2.filestatus.cbFile < 32768) ? OSData.os2.filestatus.cbFile : 8192;
    302304    pachBuffer = new char[cbBuffer];
    303305    if (pachBuffer == NULL)
    304306        throw (ERROR_NOT_ENOUGH_MEMORY);
    305     if (fReadOnly && filestatus.cbFile < 32768)
     307    if (fReadOnly && OSData.os2.filestatus.cbFile < 32768)
    306308    {
    307309        if (!bufferRead(0))
    308             throw ((int)rc);
     310            throw (kError(rc));
    309311    }
    310312}
     
    320322    if (pachBuffer)
    321323        delete pachBuffer;
    322     DosClose(hFile);
     324    DosClose(OSData.os2.hFile);
    323325}
    324326
     
    326328/**
    327329 * Reads <cbBuffer> bytes from the current file posistion into the buffer.
    328  * @returns     success indicator. (TRUE/FALSE)
     330 * @returns     0 on success. kError error number.
    329331 * @param       pvBuffer    Output buffer.
    330332 * @param       cbBuffer    Amount of bytes to read.
    331333 */
    332 BOOL            kFile::read(void *pvBuffer, long cbBuffer)
     334int             kFile::read(void *pvBuffer, long cbBuffer)
    333335{
    334336    ULONG   cbRead;
     
    336338    /* Validate parameters */
    337339    if (cbBuffer == 0)
    338         return TRUE;
     340        return NO_ERROR;
    339341    if (cbBuffer < 0)
    340342    {
    341343        rc = ERROR_INVALID_PARAMETER;
    342344        if (fThrowErrors)
    343             throw ((int)rc);
    344         return FALSE;
     345            throw (kError(rc));
     346        return rc;
    345347    }
    346348
    347349    /* refresh file status (cbFile) */
    348350    if (!refreshFileStatus())
    349         return FALSE;
     351        return rc;
    350352
    351353    /* check if valid request */
    352     if (    offVirtual > filestatus.cbFile
    353         ||  offVirtual + cbBuffer > filestatus.cbFile
     354    if (    offVirtual > OSData.os2.filestatus.cbFile
     355        ||  offVirtual + cbBuffer > OSData.os2.filestatus.cbFile
    354356        )
    355357    {   /* invalid request */
    356358        rc = ERROR_NO_DATA;
    357359    }
    358     else if (this->cbBufferValid == filestatus.cbFile && offBuffer == 0)
     360    else if (this->cbBufferValid == OSData.os2.filestatus.cbFile && offBuffer == 0)
    359361    {
    360362        /*
     
    386388            {   /* copy data from buffer */
    387389                cbRead = cbBufferValid - offVirtual + offBuffer;
    388                 cbRead = min(cbRead, cbBuffer);
     390                cbRead = KMIN(cbRead, cbBuffer);
    389391                memcpy(pvBuffer, &pachBuffer[offVirtual - offBuffer], (size_t)cbRead);
    390392                offVirtual += cbRead;
     
    396398                /* read into buffer */
    397399                if (!bufferRead(offVirtual))
    398                     return FALSE;
     400                    return rc;
    399401            }
    400402        }
     
    406408         * unbuffered read.
    407409         */
    408         rc = DosRead(hFile, pvBuffer, cbBuffer, &cbRead);
     410        rc = DosRead(OSData.os2.hFile, pvBuffer, cbBuffer, &cbRead);
    409411        if (rc == NO_ERROR)
    410412            offVirtual = offReal += cbRead;
     
    412414
    413415    /* check for error and return accordingly */
    414     if (rc)
    415     {
    416         if (fThrowErrors)
    417             throw ((int)rc);
    418         return FALSE;
    419     }
    420     return TRUE;
     416    if (rc && fThrowErrors)
     417        throw (kError(rc));
     418    return rc;
    421419}
    422420
     
    424422/**
    425423 * Reads <cbBuffer> bytes at file offset <off>.
    426  * @returns     success indicator. (TRUE/FALSE)
     424 * @returns     0 on success. kError error number.
    427425 * @param       pvBuffer    Output buffer.
    428426 * @param       cbBuffer    Amount of bytes to read.
    429427 * @param       off         Absolute file offset.
    430428 */
    431 BOOL            kFile::readAt(void *pvBuffer, long cbBuffer, long off)
    432 {
    433     return set(off) && read(pvBuffer, cbBuffer);
     429int             kFile::readAt(void *pvBuffer, long cbBuffer, long off)
     430{
     431    if (set(off))
     432        return rc;
     433    read(pvBuffer, cbBuffer);
     434    return rc;
    434435}
    435436
     
    439440 * (The memory block has a '\0' at the end just in case you
    440441 *  are using it as a long string.)
     442 * Must call the static kFile::mapFree function to free the memory block.
    441443 * @returns     Pointer to file in memory.
    442444 */
    443 void *          kFile::readFile() throw(int)
     445void *          kFile::mapFile() throw(kError)
    444446{
    445447    void *pv;
     
    450452    {
    451453        if (fThrowErrors)
    452             throw(ERROR_NOT_ENOUGH_MEMORY);
     454            throw (kError(kError::NOT_ENOUGH_MEMORY));
    453455        return NULL;
    454456    }
    455457
    456458    /* go the start of the file and read it. */
    457     if (start() && read(pv, this->getSize()))
     459    if (!start() && !read(pv, this->getSize()))
    458460        return pv; // successfull exit!
    459461
     
    467469 * Reads a single line from the file into the given buffer.
    468470 * Newline is stripped!
    469  * @returns Success indicator.
     471 * @returns 0 on success. kError error number.
    470472 * @param   pszBuffer   Pointer to string buffer.
    471473 *                      Will hold a zero-string upon successful return.
     
    475477 * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
    476478 */
    477 BOOL            kFile::readln(char *pszBuffer, long cchBuffer) throw (int)
     479int             kFile::readln(char *pszBuffer, long cchBuffer) throw(kError)
    478480{
    479481    long    cbRead;
     
    481483    /* refresh file status (cbFile) */
    482484    if (!refreshFileStatus())
    483         return FALSE;
     485        return rc;
    484486
    485487    /*
     
    488490     *      Loop buffer by buffer looking for a newline.
    489491     */
    490     cbRead = min(max((long)filestatus.cbFile - (long)offVirtual, 0), cchBuffer-1);
     492    cbRead = KMIN(KMAX((long)OSData.os2.filestatus.cbFile - (long)offVirtual, 0), cchBuffer-1);
    491493    if (cbRead == 0)
    492         return FALSE;
     494        return rc = ERROR_HANDLE_EOF;
    493495
    494496    while (cbRead > 0)
     
    502504        if (offVirtual >= offBuffer + cbBufferValid || offVirtual < offBuffer)
    503505            if (!bufferRead(offVirtual))
    504                 return FALSE;
     506                return rc;
    505507
    506508        /* Scan buffer for new line */
     
    542544            else
    543545                offVirtual++;
    544             return TRUE;
    545         }
    546     }
    547 
    548     return TRUE;
     546            return NO_ERROR;
     547        }
     548    }
     549
     550    return NO_ERROR;
    549551}
    550552
     
    552554/**
    553555 * Writes <cbBuffer> bytes to the file at the current file position.
    554  * @returns     success indicator. (TRUE/FALSE)
     556 * @returns     0 on success. kError error number.
    555557 * @param       pvBuffer    Output buffer.
    556558 * @param       cbBuffer    Amount of bytes to write.
    557559 */
    558 BOOL            kFile::write(const void *pv, long cb)
     560int             kFile::write(const void *pv, long cb)
    559561{
    560562    if (fReadOnly)
     
    604606                    offVirtual += cb + cbAddPost;
    605607                    fBufferDirty = TRUE;
    606                     return TRUE;
     608                    return NO_ERROR;
    607609                }
    608610
     
    634636                {   /* don't fit anywhere... */
    635637                    if (!bufferCommit())
    636                         return FALSE;
     638                        return rc;
    637639                    offBuffer = offVirtual;
    638640                    cbWrite = cbBufferValid = cb > cbBuffer ? cbBuffer : cb;
     
    648650            offVirtual += cbAddPost;
    649651
    650             return TRUE;
     652            return NO_ERROR;
    651653        }
    652654        else if (position())
     
    654656            ULONG   cbWrote;
    655657
    656             rc = DosWrite(hFile, (PVOID)pv, cb, &cbWrote);
     658            rc = DosWrite(OSData.os2.hFile, (PVOID)pv, cb, &cbWrote);
    657659            if (rc == NO_ERROR)
    658660            {
    659661                offVirtual = offReal += cbWrote;
    660                 return TRUE;
     662                return NO_ERROR;
    661663            }
    662664        }
     
    664666
    665667    if (fThrowErrors)
    666         throw ((int)rc);
    667     return FALSE;
     668        throw (kError(rc));
     669    return rc;
    668670}
    669671
     
    671673/**
    672674 * Write <cbBuffer> bytes at file offset <off> from <pvBuffer>.
    673  * @returns     success indicator. (TRUE/FALSE)
     675 * @returns     0 on success. kError error number.
    674676 * @param       pvBuffer    Output buffer.
    675677 * @param       cbBuffer    Amount of bytes to write.
    676678 * @param       off         Absolute file offset.
    677679 */
    678 BOOL            kFile::writeAt(void *pvBuffer, long cbBuffer, long off)
    679 {
    680     return set(off) && write(pvBuffer, cbBuffer);
     680int             kFile::writeAt(const void *pvBuffer, long cbBuffer, long off)
     681{
     682    if (set(off))
     683        return rc;
     684    return write(pvBuffer, cbBuffer);
    681685}
    682686
     
    693697 * @remark      Currently limited to 64KB of result data.
    694698 */
    695 int             kFile::printf(const char *pszFormat, ...) throw (int)
     699int             kFile::printf(const char *pszFormat, ...) throw(kError)
    696700{
    697701    long        offStart = getPos();
     
    725729/**
    726730 * Sets the filesize.
    727  * @returns     Success indicator.
     731 * @returns     0 on success. kError error number.
    728732 * @param       cbFile      New filesize.
    729733 *                          Defaults to 0xffffffff, which results in
    730734 *                          cutting the file at the current position.
    731735 */
    732 BOOL            kFile::setSize(unsigned long cbFile/*= ~0UL*/)
     736int             kFile::setSize(unsigned long cbFile/*= ~0UL*/)
    733737{
    734738    if (cbFile == ~0UL)
    735739        cbFile = offVirtual;
    736     rc = DosSetFileSize(hFile, cbFile);
     740    rc = DosSetFileSize(OSData.os2.hFile, cbFile);
    737741    if (rc != NO_ERROR && fThrowErrors)
    738         throw ((int)rc);
    739 
    740     return rc == NO_ERROR;
     742        throw (kError(rc));
     743
     744    return rc;
    741745}
    742746
     
    752756    char *  pachBuffer  = new char[1024*256];
    753757    long    pos         = AppendFile.getPos();
    754     BOOL    fAppend     = AppendFile.fThrowErrors;
    755     BOOL    fThis       = fThrowErrors;
     758    KBOOL   fAppend     = AppendFile.fThrowErrors;
     759    KBOOL   fThis       = fThrowErrors;
    756760
    757761    setThrowOnErrors();
     
    762766    AppendFile.refreshFileStatus();
    763767
    764     cb = min(1024*256, AppendFile.filestatus.cbFile);
     768    cb = KMIN(1024*256, AppendFile.OSData.os2.filestatus.cbFile);
    765769    while (cb > 0)
    766770    {
    767771        AppendFile.read(pachBuffer, cb);
    768772        write(pachBuffer, cb);
    769         cb = min(1024*256, (long)AppendFile.filestatus.cbFile - (long)AppendFile.offVirtual);
     773        cb = KMIN(1024*256, (long)AppendFile.OSData.os2.filestatus.cbFile - (long)AppendFile.offVirtual);
    770774    }
    771775
     
    781785/**
    782786 * Seek relative to the current position.
    783  * @returns     Success indicator.
     787 * @returns     0 on success. kError error number.
    784788 * @param       off     Relative reposition.
    785789 */
    786 BOOL            kFile::move(long off)
     790int             kFile::move(long off)
    787791{
    788792    if ((off + offVirtual) & 0x80000000UL) /* above 2GB or negative */
     
    790794    else
    791795    {
    792         if (off + offVirtual > filestatus.cbFile && fReadOnly) /* can't expand readonly file. */
     796        if (off + offVirtual > OSData.os2.filestatus.cbFile && fReadOnly) /* can't expand readonly file. */
    793797            rc = ERROR_HANDLE_EOF;
    794798        else
    795799        {
    796800            offVirtual += off;
    797             return TRUE;
     801            return rc = NO_ERROR;
    798802        }
    799803    }
    800804
    801805    if (fThrowErrors)
    802         throw ((int)rc);
    803     return FALSE;
     806        throw (kError(rc));
     807    return rc;
    804808}
    805809
     
    807811/**
    808812 * Seek to an absolute position in the file (off).
    809  * @returns     Success indicator.
     813 * @returns     0 on success. kError error number.
    810814 * @param       off     New file position.
    811815 */
    812 BOOL            kFile::set(long off)
     816int             kFile::set(long off)
    813817{
    814818    if (off < 0)
     
    816820    else
    817821    {
    818         if ((unsigned long)off > filestatus.cbFile && fReadOnly)
     822        if ((unsigned long)off > OSData.os2.filestatus.cbFile && fReadOnly)
    819823            rc = ERROR_HANDLE_EOF;
    820824        else
    821825        {
    822826            offVirtual = off;
    823             rc = NO_ERROR;
    824             return TRUE;
     827            return rc = NO_ERROR;
    825828        }
    826829    }
    827830    if (fThrowErrors)
    828         throw ((int)rc);
    829     return FALSE;
     831        throw (kError(rc));
     832    return rc;
    830833}
    831834
     
    833836/**
    834837 * Seek to the end of the file.
    835  * @returns     Success indicator. TRUE / FALSE.
     838 * @returns     0 on success. kError error number.
    836839 * @remark      Will only throw error if refreshFileStatus failes.
    837840 */
    838 BOOL            kFile::end()
     841int             kFile::end()
    839842{
    840843    if (!refreshFileStatus())
    841         return FALSE;
    842 
    843     if (!fReadOnly && pachBuffer && offBuffer != ~0UL && offBuffer + cbBufferValid > filestatus.cbFile)
     844        return rc;
     845
     846    if (!fReadOnly && pachBuffer && offBuffer != ~0UL && offBuffer + cbBufferValid > OSData.os2.filestatus.cbFile)
    844847        /* a writable file with buffer might have uncommited data in the buffer. */
    845848        offVirtual = offBuffer + cbBufferValid;
    846849    else
    847         offVirtual = filestatus.cbFile;
    848 
    849     rc = NO_ERROR;
    850     return TRUE;
     850        offVirtual = OSData.os2.filestatus.cbFile;
     851
     852    return rc = NO_ERROR;
    851853}
    852854
     
    854856/**
    855857 * Seek to the start of the file.
    856  * @returns     TRUE.
     858 * @returns     0 on success. kError error number.
    857859 * @remark      Will never throw errors.
    858860 */
    859 BOOL            kFile::start()
     861int             kFile::start()
    860862{
    861863    offVirtual = 0;
    862     rc = NO_ERROR;
    863     return TRUE;
     864    return rc = NO_ERROR;
    864865}
    865866
     
    876877        return -1;
    877878
    878     return filestatus.cbFile;
     879    return OSData.os2.filestatus.cbFile;
    879880}
    880881
     
    897898 * @remark      Will only throw error if refreshFileStatus failes.
    898899 */
    899 BOOL            kFile::isEOF()
     900KBOOL           kFile::isEOF()
    900901{
    901902    #if 0
    902     throw(ERROR_NOT_SUPPORTED); //this method don't currently work! Need to use flag!
     903    throw (kError(kError::NOT_SUPPORTED)); //this method don't currently work! Need to use flag!
    903904    #else
    904905    if (!fReadOnly && !refreshFileStatus())
    905         return (BOOL)-1;
    906 
    907     return filestatus.cbFile <= offVirtual; //??? - !!!
     906        return (KBOOL)-1;
     907
     908    return OSData.os2.filestatus.cbFile <= offVirtual; //??? - !!!
    908909    #endif
    909910}
     
    913914 * Set error behaviour to fail by throwing the OS/2 return code when an
    914915 * error occures.
    915  * @returns     TRUE;
    916916 * @remark      Will never throw errors.
    917917 */
    918 BOOL            kFile::setThrowOnErrors()
     918void            kFile::setThrowOnErrors()
    919919{
    920920    fThrowErrors = TRUE;
    921921    rc = NO_ERROR;
    922     return TRUE;
    923922}
    924923
     
    926925/**
    927926 * Set error behaviour to fail by return FALSE when an error has occures.
    928  * @returns     TRUE;
    929927 * @remark      Will never throw errors.
    930928 */
    931 BOOL            kFile::setFailOnErrors()
     929void            kFile::setFailOnErrors()
    932930{
    933931    fThrowErrors = FALSE;
    934932    rc = NO_ERROR;
    935     return TRUE;
    936933}
    937934
     
    957954 * @remark  May throw errors.
    958955 */
    959 void *kFile::readFile(const char *pszFilename)
     956void *kFile::mapFile(const char *pszFilename)
    960957{
    961958    kFile file(pszFilename);
    962     return file.readFile();
    963 }
    964 
     959    file.setThrowOnErrors();
     960    return file.mapFile();
     961}
     962
     963
     964
     965/**
     966 * Frees a file mapping done by one of the mapFile members of kFile.
     967 * @param   pvFileMapping   The pointer mapFile returned.
     968 * @author  knut st. osmundsen (knut.stange.osmundsen@mynd.no)
     969 */
     970void kFile::mapFree(void *pvFileMapping)
     971{
     972    if (pvFileMapping)
     973        free(pvFileMapping);
     974}
     975
Note: See TracChangeset for help on using the changeset viewer.