Public Member Functions | Public Attributes | Private Attributes

fio_File Class Reference
[Classes for large file i/o, relative file, and DataBase]

Basic (super) class for large file IO. More...

#include <fio_File.h>

Inheritance diagram for fio_File:
Inheritance graph
[legend]
Collaboration diagram for fio_File:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fio_File (bool a_readOnly, const ivd_FileID_t a_fileID, const cmn_Path a_path, const string a_fileName)
 Instantiate fio_File class with unique file ID and file name.
virtual ~fio_File ()
string & GetFileName () const
ivd_FileID_t GetFileID () const
ivd_FileRetSize_t PosWrite (ivd_FilePosition_t a_position, const void *a_buffer_p, ivd_FileBufSize_t a_size) const
 over write method to add a mutex
ivd_FileRetSize_t PosRead (ivd_FilePosition_t a_position, void *a_buffer_p, ivd_FileBufSize_t a_size)
 over write method to add a mutex
const cmn_PathGetPath ()

Public Attributes

 log_CLASSID_m
 Macro for class name member.

Private Attributes

const ivd_FileID_t m_fileID
 File ID is used by inheritor classes, specially for transaction handle.
const cmn_Path m_path
const string m_fileName
cmn_Mutex m_file_x
 atomic access to file psition and read or write

Detailed Description

Basic (super) class for large file IO.

It supports 64 bit seek, but it does not support reading or writing blocks larger than 2GiB!

Definition at line 43 of file fio_File.h.


Constructor & Destructor Documentation

fio_File::fio_File ( bool  a_readOnly,
const ivd_FileID_t  a_fileID,
const cmn_Path  a_path,
const string  a_fileName 
)

Instantiate fio_File class with unique file ID and file name.

If you don't specify path the current working directory is used.

See also:
m_fileID

Definition at line 61 of file fio_File.cpp.

References fom_OPEN_ALWAYS, fom_READWRITE, and cmn_File::OpenF().

            : cmn_File(a_path + a_fileName),
              m_fileID(a_fileID),
              m_path(a_path),
              m_fileName(a_fileName)
//              m_pathAndFile(m_path + m_fileName)
{
    UInt32_t mode = 0;
    if (a_readOnly) {
        mode = fom_READ;
    }
    else {
        mode = fom_READWRITE | fom_OPEN_ALWAYS | fom_FILE_NO_SHARE_WRITE;
    }
    OpenF(mode);
}

Here is the call graph for this function:

fio_File::~fio_File (  )  [virtual]

Definition at line 96 of file fio_File.cpp.

                     { 
//  CloseF();
}


Member Function Documentation

ivd_FileID_t fio_File::GetFileID ( void   )  const [inline]
string& fio_File::GetFileName (  )  const [inline]
const cmn_Path& fio_File::GetPath (  )  [inline]

Definition at line 105 of file fio_File.h.

{ return m_path;};

ivd_FileRetSize_t fio_File::PosRead ( ivd_FilePosition_t  a_position,
void *  a_buffer_p,
ivd_FileBufSize_t  a_size 
)

over write method to add a mutex

Definition at line 142 of file fio_File.cpp.

References m_file_x, cmn_File::ReadF(), and cmn_File::SeekF().

Referenced by fio_CirFileTrans::CheckBlockChain(), fio_CirFileTrans::fio_CirFileTrans(), fio_CirFileTrans::GetRFIdxFromNextBlock(), fio_CirFileTrans::GetRNIdxFromNextBlock(), fio_PermJourInfo_t::Init(), fio_JourHandle::JourRead(), fio_RelFile::ReadListOfUnusedVector(), fio_RelFile::ReadRec(), fsc_nsStream::RemoveLeftVectors(), fsc_RawUpdate::ScanAllCopy(), fsc_RawScan::ScanAllCopy(), fsc_RawUpdate::ScanAllGeneration(), fsc_RawScan::ScanAllGeneration(), fsc_RawUpdate::ScanAllSplit(), fsc_RawScan::ScanAllSplit(), fio_CirFileTrans::SyncRelFileObj(), and fsc_nsStream::Write2DB().

                                         {
//    log_FUNC_m(PosRead);
    cmn_MutexLock l(m_file_x);
    SeekF(a_position);
    UInt32_t read = ReadF(a_buffer_p, a_size);
    // when read over file size fill buffer with zeroes
    if (read < a_size) {
        //log_DBG_m(dbg_DETAIL, "Read data over file " << m_fileID 
        //              << ", position " << a_position << endl <<
        //    cmn_HexDump(a_buffer_p, a_size, a_size, false) );
        memset((char*)a_buffer_p + read, 0, a_size - read);
        return a_size;
    }
    return read;
}

Here is the call graph for this function:

Here is the caller graph for this function:

ivd_FileRetSize_t fio_File::PosWrite ( ivd_FilePosition_t  a_position,
const void *  a_buffer_p,
ivd_FileBufSize_t  a_size 
) const

over write method to add a mutex

Definition at line 117 of file fio_File.cpp.

References ivd_BaseException::GetFriendly(), ie_FATAL_ERROR, m_file_x, m_fileName, m_path, cmn_File::SeekF(), and cmn_File::WriteF().

Referenced by fio_JourHandle::JourFlush(), fio_JourHandle::JourWrite(), fio_RelFile::PosWrite(), Update(), and fio_PermJourInfo_t::WriteInfo().

                                                {

    cmn_MutexLock l(m_file_x);

    ivd_FileBufSize_t ret;
    try {
        SeekF(a_position);     
        ret = WriteF(a_buffer_p, a_size);
        if (ret < a_size) {
            ostringstream sstr;
            sstr << "Write to " << (m_path + m_fileName) << ", size " << a_size <<
                ", but write only " << ret;
            throw ivd_SysError(ENOSPC, sstr.str(), true);
        }
    }
    catch (ivd_SysError &se) {
        throw ivd_InternalError(ie_FATAL_ERROR, se.GetFriendly(), true);
    }
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Macro for class name member.

Reimplemented from cmn_File.

Reimplemented in fio_CirFileTrans, fio_JourFile, fio_PermDBinfoMgr, fio_RelFile, fio_RelFileTrans, and fio_VarLenRFT.

Definition at line 86 of file fio_File.h.

cmn_Mutex fio_File::m_file_x [mutable, private]

atomic access to file psition and read or write

Definition at line 82 of file fio_File.h.

Referenced by PosRead(), and PosWrite().

File ID is used by inheritor classes, specially for transaction handle.

It must be unique in the scope of DataBase. If you use class just for a file, it doesn't matter what value m_fileID has.

See also:
ivd_Transaction

Definition at line 76 of file fio_File.h.

const string fio_File::m_fileName [private]

Definition at line 78 of file fio_File.h.

Referenced by PosWrite().

const cmn_Path fio_File::m_path [private]

Definition at line 77 of file fio_File.h.

Referenced by PosWrite().


The documentation for this class was generated from the following files: