#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) |
CheckedFile & | operator<< (const e57::ustring &s) |
CheckedFile & | operator<< (double d) |
CheckedFile & | operator<< (float f) |
CheckedFile & | operator<< (int64_t i) |
CheckedFile & | operator<< (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 |
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::CheckedFile | ( | const char * | input, |
uint64_t | size, | ||
ReadChecksumPolicy | policy | ||
) |
References physicalToLogical().
CheckedFile::~CheckedFile | ( | ) |
??? what if already closed?
References close().
void CheckedFile::close | ( | ) |
References close(), e57::E57_ERROR_CLOSE_FAILED, and e57::toString().
Referenced by e57::ImageFileImpl::cancel(), close(), e57::ImageFileImpl::close(), femexamples.examplesgui.FemExamples::reject(), unlink(), and ~CheckedFile().
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().
e57::ustring e57::CheckedFile::fileName | ( | ) | const |
uint64_t CheckedFile::length | ( | OffsetMode | omode = Logical | ) |
References Physical.
Referenced by CheckedFile(), e57::ImageFileImpl::close(), PathScripts.PathStock.StockFromBase::execute(), PathScripts.PathDressupDogbone.ObjectDressup::execute(), extend(), PathScripts.PathFeatureExtensions.Extension::getSubLink(), PathScripts.PathFeatureExtensions.Extension::getWire(), Mod.PartDesign.Scripts.FilletArc.Vector::norm(), read(), and write().
|
static |
References logicalPageSize, and physicalPageSize.
Referenced by seek(), e57::BlobNodeImpl::writeXml(), and e57::CompressedVectorNodeImpl::writeXml().
CheckedFile & CheckedFile::operator<< | ( | const e57::ustring & | s | ) |
References write().
CheckedFile & CheckedFile::operator<< | ( | double | d | ) |
CheckedFile & CheckedFile::operator<< | ( | float | f | ) |
CheckedFile & CheckedFile::operator<< | ( | int64_t | i | ) |
CheckedFile & CheckedFile::operator<< | ( | uint64_t | i | ) |
|
static |
References logicalPageSize, physicalPageSizeLog2, and physicalPageSizeMask.
Referenced by CheckedFile(), e57::ImageFileImpl::construct2(), extend(), and position().
uint64_t CheckedFile::position | ( | OffsetMode | omode = Logical | ) |
Get current file cursor position
References Physical, and physicalToLogical().
Referenced by WorkingPlane.Plane::alignToPointAndAxis(), WorkingPlane.Plane::alignToPointAndAxis_SVG(), e57::ImageFileImpl::close(), WorkingPlane.Plane::copy(), ifc2x3.ifcsweptsurface::dim(), ifc2x3.ifcelementarysurface::dim(), WorkingPlane.Plane::getGlobalCoords(), WorkingPlane.Plane::getLocalCoords(), WorkingPlane.Plane::getParameters(), WorkingPlane.Plane::getPlacement(), WorkingPlane.Plane::offsetToPoint(), WorkingPlane.Plane::projectPoint(), read(), WorkingPlane.Plane::restore(), WorkingPlane.Plane::save(), WorkingPlane.Plane::setFromParameters(), WorkingPlane.Plane::setFromPlacement(), and write().
void CheckedFile::read | ( | char * | buf, |
size_t | nRead, | ||
size_t | bufSize = 0 |
||
) |
Allocate temp page buffer
When done, leave cursor just past end of last byte read
References e57::CHECKSUM_POLICY_ALL, e57::CHECKSUM_POLICY_NONE, e57::E57_ERROR_INTERNAL, length(), Logical, logicalPageSize, physicalPageSize, position(), seek(), and e57::toString().
Referenced by E57FileInputStream::readBytes(), gzip_utf8.GzipFile::readline(), e57::PacketReadCache::readPacket(), and gzip_utf8.GzipFile::seek().
void CheckedFile::seek | ( | uint64_t | offset, |
OffsetMode | omode = Logical |
||
) |
References logicalToPhysical(), draftfunctions.offset::offset(), and Physical.
Referenced by e57::ImageFileImpl::close(), extend(), read(), E57FileInputStream::readBytes(), e57::PacketReadCache::readPacket(), and write().
void CheckedFile::unlink | ( | ) |
Try to remove the file, don't report a failure
References close().
Referenced by e57::ImageFileImpl::cancel().
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().
|
staticconstexpr |
Referenced by extend(), logicalToPhysical(), physicalToLogical(), read(), and write().
|
staticconstexpr |
Referenced by e57::ImageFileImpl::close(), extend(), logicalToPhysical(), read(), and write().
|
staticconstexpr |
Referenced by physicalToLogical().
|
staticconstexpr |
Referenced by physicalToLogical().