e57::CheckedFile Class Reference

#include <CheckedFile.h>

Public Types

enum  Mode { ReadOnly , WriteCreate , WriteExisting }
enum  OffsetMode { Logical , Physical }

Public Member Functions

 CheckedFile (const char *input, uint64_t size, ReadChecksumPolicy policy)
 CheckedFile (const e57::ustring &fileName, Mode mode, ReadChecksumPolicy policy)
void close ()
void extend (uint64_t newLength, OffsetMode omode=Logical)
e57::ustring fileName () const
uint64_t length (OffsetMode omode=Logical)
CheckedFileoperator<< (const e57::ustring &s)
CheckedFileoperator<< (double d)
CheckedFileoperator<< (float f)
CheckedFileoperator<< (int64_t i)
CheckedFileoperator<< (uint64_t i)
uint64_t position (OffsetMode omode=Logical)
void read (char *buf, size_t nRead, size_t bufSize=0)
void seek (uint64_t offset, OffsetMode omode=Logical)
void unlink ()
void write (const char *buf, size_t nWrite)
 ~CheckedFile ()

Static Public Member Functions

static uint64_t logicalToPhysical (uint64_t logicalOffset)
static uint64_t physicalToLogical (uint64_t physicalOffset)

Static Public Attributes

static constexpr size_t logicalPageSize = physicalPageSize - 4
static constexpr size_t physicalPageSize = 1 << physicalPageSizeLog2
static constexpr size_t physicalPageSizeLog2 = 10
static constexpr uint64_t physicalPageSizeMask = physicalPageSize - 1

Member Enumeration Documentation

◆ Mode


◆ OffsetMode


Constructor & Destructor Documentation

◆ CheckedFile() [1/2]

CheckedFile::CheckedFile ( const e57::ustring fileName,
Mode  mode,
ReadChecksumPolicy  policy 

File truncated to zero length if already exists

References length(), Physical, physicalToLogical(), ReadOnly, WriteCreate, and WriteExisting.

◆ CheckedFile() [2/2]

CheckedFile::CheckedFile ( const char *  input,
uint64_t  size,
ReadChecksumPolicy  policy 

References physicalToLogical().

◆ ~CheckedFile()

CheckedFile::~CheckedFile ( )

??? what if already closed?

References close().

Member Function Documentation

◆ close()

◆ extend()

void CheckedFile::extend ( uint64_t  newLength,
OffsetMode  omode = Logical 

Make sure we are trying to make file longer

Calc how may zero bytes we have to add to end

Seek to current end of file

Calc first write size (may be partial page) Watch out for different int sizes here.

Allocate temp page buffer

When done, leave cursor at end of file

References e57::E57_ERROR_FILE_IS_READ_ONLY, e57::E57_ERROR_INTERNAL, length(), Logical, logicalPageSize, Physical, physicalPageSize, physicalToLogical(), seek(), and e57::toString().

Referenced by e57::ImageFileImpl::allocateSpace().

◆ fileName()

e57::ustring e57::CheckedFile::fileName ( ) const

◆ length()

◆ logicalToPhysical()

uint64_t e57::CheckedFile::logicalToPhysical ( uint64_t  logicalOffset)

◆ operator<<() [1/5]

CheckedFile & CheckedFile::operator<< ( const e57::ustring s)

References write().

◆ operator<<() [2/5]

CheckedFile & CheckedFile::operator<< ( double  d)

◆ operator<<() [3/5]

CheckedFile & CheckedFile::operator<< ( float  f)

◆ operator<<() [4/5]

CheckedFile & CheckedFile::operator<< ( int64_t  i)

◆ operator<<() [5/5]

CheckedFile & CheckedFile::operator<< ( uint64_t  i)

◆ physicalToLogical()

uint64_t e57::CheckedFile::physicalToLogical ( uint64_t  physicalOffset)

◆ position()

◆ read()

void CheckedFile::read ( char *  buf,
size_t  nRead,
size_t  bufSize = 0 

◆ seek()

◆ unlink()

void CheckedFile::unlink ( )

Try to remove the file, don't report a failure

References close().

Referenced by e57::ImageFileImpl::cancel().

◆ write()

void CheckedFile::write ( const char *  buf,
size_t  nWrite 

Allocate temp page buffer

When done, leave cursor just past end of buf

References e57::E57_ERROR_FILE_IS_READ_ONLY, length(), Logical, logicalPageSize, Physical, physicalPageSize, position(), and seek().

Referenced by e57::ImageFileImpl::close(), operator<<(), and gzip_utf8.GzipFile::seek().

Member Data Documentation

◆ logicalPageSize

constexpr size_t CheckedFile::logicalPageSize = physicalPageSize - 4

◆ physicalPageSize

constexpr size_t CheckedFile::physicalPageSize = 1 << physicalPageSizeLog2

◆ physicalPageSizeLog2

constexpr size_t CheckedFile::physicalPageSizeLog2 = 10

Referenced by physicalToLogical().

◆ physicalPageSizeMask

constexpr uint64_t CheckedFile::physicalPageSizeMask = physicalPageSize - 1

Referenced by physicalToLogical().

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