![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
#include <CheckedFile.h>

Public Types | |
| enum | Mode { ReadOnly , WriteCreate , WriteExisting } |
| enum | OffsetMode { Logical , Physical } |
Public Member Functions | |
| CheckedFile (const e57::ustring &fileName, Mode mode, ReadChecksumPolicy policy) | |
| CheckedFile (const char *input, uint64_t size, ReadChecksumPolicy policy) | |
| ~CheckedFile () | |
| void | read (char *buf, size_t nRead, size_t bufSize=0) |
| void | write (const char *buf, size_t nWrite) |
| CheckedFile & | operator<< (const e57::ustring &s) |
| CheckedFile & | operator<< (int64_t i) |
| CheckedFile & | operator<< (uint64_t i) |
| CheckedFile & | operator<< (float f) |
| CheckedFile & | operator<< (double d) |
| void | seek (uint64_t offset, OffsetMode omode=Logical) |
| uint64_t | position (OffsetMode omode=Logical) |
| uint64_t | length (OffsetMode omode=Logical) |
| void | extend (uint64_t newLength, OffsetMode omode=Logical) |
| e57::ustring | fileName () const |
| void | close () |
| void | unlink () |
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 | physicalPageSizeLog2 = 10 |
| static constexpr size_t | physicalPageSize = 1 << physicalPageSizeLog2 |
| static constexpr uint64_t | physicalPageSizeMask = physicalPageSize - 1 |
| static constexpr size_t | logicalPageSize = physicalPageSize - 4 |
Definition at line 42 of file CheckedFile.h.
| Enumerator | |
|---|---|
| ReadOnly | |
| WriteCreate | |
| WriteExisting | |
Definition at line 51 of file CheckedFile.h.
| Enumerator | |
|---|---|
| Logical | |
| Physical | |
Definition at line 58 of file CheckedFile.h.
| CheckedFile::CheckedFile | ( | const e57::ustring & | fileName, |
| Mode | mode, | ||
| ReadChecksumPolicy | policy | ||
| ) |
File truncated to zero length if already exists
Definition at line 139 of file CheckedFile.cpp.
References length(), O_BINARY, Physical, physicalToLogical(), ReadOnly, SEEK_END, SEEK_SET, WriteCreate, and WriteExisting.
| CheckedFile::CheckedFile | ( | const char * | input, |
| uint64_t | size, | ||
| ReadChecksumPolicy | policy | ||
| ) |
Definition at line 168 of file CheckedFile.cpp.
References physicalToLogical(), SEEK_END, SEEK_SET, and size.
| CheckedFile::~CheckedFile | ( | ) |
| void CheckedFile::close | ( | ) |
Definition at line 636 of file CheckedFile.cpp.
References e57::E57_ERROR_CLOSE_FAILED, E57_EXCEPTION2, result, and e57::toString().
Referenced by e57::ImageFileImpl::cancel(), e57::ImageFileImpl::close(), 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
Definition at line 539 of file CheckedFile.cpp.
References e57::E57_ERROR_FILE_IS_READ_ONLY, e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, length(), Logical, logicalPageSize, Physical, physicalPageSize, physicalToLogical(), seek(), and e57::toString().
Referenced by e57::ImageFileImpl::allocateSpace().
|
inline |
Definition at line 79 of file CheckedFile.h.
| uint64_t CheckedFile::length | ( | OffsetMode | omode = Logical | ) |
Definition at line 515 of file CheckedFile.cpp.
References Physical, SEEK_CUR, SEEK_END, and SEEK_SET.
Referenced by CheckedFile(), e57::ImageFileImpl::close(), extend(), read(), and write().
|
inlinestatic |
Definition at line 112 of file CheckedFile.h.
References logicalPageSize, and physicalPageSize.
Referenced by seek(), e57::BlobNodeImpl::writeXml(), and e57::CompressedVectorNodeImpl::writeXml().
| CheckedFile & CheckedFile::operator<< | ( | const e57::ustring & | s | ) |
Definition at line 345 of file CheckedFile.cpp.
References write().
| CheckedFile & CheckedFile::operator<< | ( | double | d | ) |
Definition at line 371 of file CheckedFile.cpp.
| CheckedFile & CheckedFile::operator<< | ( | float | f | ) |
Definition at line 365 of file CheckedFile.cpp.
| CheckedFile & CheckedFile::operator<< | ( | int64_t | i | ) |
Definition at line 351 of file CheckedFile.cpp.
| CheckedFile & CheckedFile::operator<< | ( | uint64_t | i | ) |
Definition at line 358 of file CheckedFile.cpp.
|
inlinestatic |
Definition at line 120 of file CheckedFile.h.
References logicalPageSize, min(), physicalPageSizeLog2, and physicalPageSizeMask.
Referenced by CheckedFile(), e57::ImageFileImpl::construct2(), extend(), and position().
| uint64_t CheckedFile::position | ( | OffsetMode | omode = Logical | ) |
Get current file cursor position
Definition at line 502 of file CheckedFile.cpp.
References Physical, physicalToLogical(), and SEEK_CUR.
Referenced by e57::ImageFileImpl::close(), read(), 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
Definition at line 221 of file CheckedFile.cpp.
References e57::CHECKSUM_POLICY_ALL, e57::CHECKSUM_POLICY_NONE, e57::E57_ERROR_INTERNAL, E57_EXCEPTION2, length(), Logical, logicalPageSize, min(), physicalPageSize, position(), seek(), and e57::toString().
Referenced by E57FileInputStream::readBytes(), and e57::PacketReadCache::readPacket().
| void CheckedFile::seek | ( | uint64_t | offset, |
| OffsetMode | omode = Logical |
||
| ) |
Definition at line 444 of file CheckedFile.cpp.
References logicalToPhysical(), offset, Physical, and SEEK_SET.
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
Definition at line 665 of file CheckedFile.cpp.
References close(), QtCompat::endl(), and result.
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
Definition at line 284 of file CheckedFile.cpp.
References e57::E57_ERROR_FILE_IS_READ_ONLY, E57_EXCEPTION2, length(), Logical, logicalPageSize, min(), Physical, physicalPageSize, position(), and seek().
Referenced by e57::ImageFileImpl::close(), and operator<<().
|
staticconstexpr |
Definition at line 48 of file CheckedFile.h.
Referenced by extend(), logicalToPhysical(), physicalToLogical(), read(), and write().
|
staticconstexpr |
Definition at line 46 of file CheckedFile.h.
Referenced by e57::ImageFileImpl::close(), extend(), logicalToPhysical(), read(), and write().
|
staticconstexpr |
Definition at line 45 of file CheckedFile.h.
Referenced by physicalToLogical().
|
staticconstexpr |
Definition at line 47 of file CheckedFile.h.
Referenced by physicalToLogical().