Public Member Functions | Private Attributes

cmn_FileTest Class Reference

#include <cmn_filetest.h>

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

List of all members.

Public Member Functions

 cmn_FileTest (const cmn_Path &a_fullPathUTF8)
 cmn_FileTest (const cmn_Path &a_fullPathUTF8, const UInt64_t a_size)
void WriteADS ()
void WriteContents (UInt64_t m_wsize, char m_charToWrite)
void ReadContents (UInt64_t m_rsize)
void OpenContents ()

Private Attributes

 log_CLASSID_m

Detailed Description

Definition at line 34 of file cmn_filetest.h.


Constructor & Destructor Documentation

cmn_FileTest::cmn_FileTest ( const cmn_Path a_fullPathUTF8  ) 

Definition at line 59 of file cmn_filetest.cpp.

    : cmn_File(a_fullPathUTF8) {

    //empty

}

cmn_FileTest::cmn_FileTest ( const cmn_Path a_fullPathUTF8,
const UInt64_t  a_size 
)

Definition at line 52 of file cmn_filetest.cpp.

    : cmn_File(a_fullPathUTF8, a_size) {

    //empty

}


Member Function Documentation

void cmn_FileTest::OpenContents (  ) 

Definition at line 149 of file cmn_filetest.cpp.

References fom_OPEN_EXISTING, and cmn_File::OpenF().

Referenced by _tmain(), and RecAccess::ProcessEntry().

Here is the call graph for this function:

Here is the caller graph for this function:

void cmn_FileTest::ReadContents ( UInt64_t  m_rsize  ) 

Definition at line 131 of file cmn_filetest.cpp.

References BlkSize_c(), dbg_NORM, fom_OPEN_EXISTING, fom_READ, log_DBG_m, log_FUNC_m, cmn_File::OpenF(), and cmn_File::ReadF().

Referenced by _tmain(), and RecAccess::ProcessEntry().

                                               {
    log_FUNC_m(ReadContents);
    
    OpenF(fom_READ | fom_OPEN_EXISTING);
    string buf;

    for (ivd_FileSize_t rem(a_rsize); rem > 0;) {
        UInt64_t toRead = (rem > BlkSize_c) ? BlkSize_c : rem;
        UInt32_t read = ReadF(&buf[0], toRead);
        if (read < toRead) {
            log_DBG_m(dbg_NORM,
                "Read less than requested - probbaly reached end of file.");
              break;
        }
        rem -= read;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cmn_FileTest::WriteADS (  ) 

Definition at line 67 of file cmn_filetest.cpp.

                           {

    //empty

}

void cmn_FileTest::WriteContents ( UInt64_t  m_wsize,
char  m_charToWrite 
)

Definition at line 73 of file cmn_filetest.cpp.

References BlkSize_c(), dbg_NORM, cmn_File::Exists(), fom_CREATE_NEW, fom_OPEN_ALWAYS, fom_WRITE, cmn_Time::GetMilliTime(), cmn_Time::GetTime_t(), log_DBG_m, log_FUNC_m, cmn_File::OpenF(), cmn_Time::Time2hms(), and cmn_File::WriteF().

Referenced by _tmain(), and RecAccess::ProcessEntry().

                                                                   {
    log_FUNC_m(WriteContents);
    string mode;
    
    if(Exists()) {
        OpenF(fom_WRITE | fom_OPEN_ALWAYS);
        mode = "existing";
    }
    else {
        OpenF(fom_WRITE | fom_CREATE_NEW);
        mode = "new";
    }
    
    string buf(BlkSize_c, a_charToWrite);
    
    UInt64_t reportSize(0);
    cmn_Time startTime;

    //cout << "Writing to " << mode << " file " << this->GetFullPathRef() << ", size: " << a_size << endl;
    
    for (ivd_FileSize_t rem(a_size); rem > 0;) {
        UInt64_t toWrite = (rem > BlkSize_c) ? BlkSize_c : rem;
        UInt32_t written = WriteF(buf.data(), toWrite);
        reportSize += written;

        if (reportSize > 209715200) {
            cmn_Time endTime;
            cmn_Time diffTime = endTime - startTime;
            
            UInt64_t msec =
                UInt64_t(diffTime.GetTime_t()) * 1000 +
                diffTime.GetMilliTime();

            //cout << "msec == " << msec << endl;

            if (msec == 0) msec = 1;

            UInt64_t speed = (reportSize * 1000)  / (msec * 1024) ;

            ostringstream sstr;
            sstr << endTime.Time2hms() << ", written:";
            sstr << reportSize/1024 << " KB (" << speed << " KB/s).";
            cout << sstr.str() << endl;
            
            reportSize = 0;
            startTime.Refresh();
        }

        if (written < toWrite) {
            log_DBG_m(dbg_NORM,
                "Written to file less then requested. Maybe no space on disk.");
            break;
        }
        rem -= written;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Reimplemented from cmn_File.

Definition at line 44 of file cmn_filetest.h.


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