|
LogCabin
|
Provides random access to a file. More...
#include <FilesystemUtil.h>
Public Member Functions | |
| FileContents (const File &file) | |
| Constructor. | |
| ~FileContents () | |
| Destructor. | |
| uint64_t | getFileLength () |
| Return the length of the file. | |
| void | copy (uint64_t offset, void *buf, uint64_t length) |
| Copy some number of bytes of the file into a user-supplied buffer. | |
| uint64_t | copyPartial (uint64_t offset, void *buf, uint64_t maxLength) |
| Copy up to some number of bytes of the file into a user-supplied buffer. | |
| template<typename T = void> | |
| const T * | get (uint64_t offset, uint64_t length) |
| Get a pointer to a region of the file. | |
Private Member Functions | |
| const void * | getHelper (uint64_t offset, uint64_t length) |
| Used internally by get(). | |
| FileContents (const FileContents &) | |
| FileContents & | operator= (const FileContents &) |
Private Attributes | |
| File | file |
| An open file descriptor for the file to read. | |
| uint64_t | fileLen |
| The number of bytes in the file. | |
| const void * | map |
| The value returned by mmap(), or NULL for empty files. | |
Provides random access to a file.
This implementation currently works by mmaping the file and working from the in-memory copy.
Definition at line 284 of file FilesystemUtil.h.
| LogCabin::Storage::FilesystemUtil::FileContents::FileContents | ( | const File & | file | ) | [explicit] |
Constructor.
| file | An open file descriptor for the file to read. |
Definition at line 445 of file FilesystemUtil.cc.
Destructor.
Definition at line 460 of file FilesystemUtil.cc.
| LogCabin::Storage::FilesystemUtil::FileContents::FileContents | ( | const FileContents & | ) | [private] |
| uint64_t LogCabin::Storage::FilesystemUtil::FileContents::getFileLength | ( | ) | [inline] |
Return the length of the file.
Definition at line 297 of file FilesystemUtil.h.
| void LogCabin::Storage::FilesystemUtil::FileContents::copy | ( | uint64_t | offset, |
| void * | buf, | ||
| uint64_t | length | ||
| ) |
Copy some number of bytes of the file into a user-supplied buffer.
If there are not enough bytes in the file, this will PANIC. See copyPartial if that's not what you want.
| offset | The number of bytes into the file at which to start copying. | |
| [out] | buf | The destination buffer to copy into. |
| length | The number of bytes to copy. |
Definition at line 471 of file FilesystemUtil.cc.
| uint64_t LogCabin::Storage::FilesystemUtil::FileContents::copyPartial | ( | uint64_t | offset, |
| void * | buf, | ||
| uint64_t | maxLength | ||
| ) |
Copy up to some number of bytes of the file into a user-supplied buffer.
| offset | The number of bytes into the file at which to start copying. | |
| [out] | buf | The destination buffer to copy into. |
| maxLength | The maximum number of bytes to copy. |
Definition at line 480 of file FilesystemUtil.cc.
| const T* LogCabin::Storage::FilesystemUtil::FileContents::get | ( | uint64_t | offset, |
| uint64_t | length | ||
| ) | [inline] |
Get a pointer to a region of the file.
If there are not enough bytes in the file, this will PANIC.
| T | The return type is casted to a pointer of T. |
| offset | The number of bytes into the file at which to return the pointer. |
| length | The number of bytes that must be valid after the offset. |
Definition at line 347 of file FilesystemUtil.h.
| const void * LogCabin::Storage::FilesystemUtil::FileContents::getHelper | ( | uint64_t | offset, |
| uint64_t | length | ||
| ) | [private] |
Used internally by get().
Definition at line 490 of file FilesystemUtil.cc.
| FileContents& LogCabin::Storage::FilesystemUtil::FileContents::operator= | ( | const FileContents & | ) | [private] |
An open file descriptor for the file to read.
Definition at line 355 of file FilesystemUtil.h.
uint64_t LogCabin::Storage::FilesystemUtil::FileContents::fileLen [private] |
The number of bytes in the file.
Definition at line 357 of file FilesystemUtil.h.
const void* LogCabin::Storage::FilesystemUtil::FileContents::map [private] |
The value returned by mmap(), or NULL for empty files.
Definition at line 359 of file FilesystemUtil.h.
1.7.6.1