feisty meow concerns codebase
2.140
|
Supports reading and writing to very large files, > 4 gigabytes. More...
#include <huge_file.h>
Public Types | |
enum | outcomes { OKAY = basis::common::OKAY , FAILURE = basis::common::FAILURE , ACCESS_DENIED = basis::common::ACCESS_DENIED , BAD_INPUT = basis::common::BAD_INPUT } |
Public Member Functions | |
huge_file (const basis::astring &filename, const basis::astring &permissions) | |
opens "filename" for access, where it presumably is a very large file. More... | |
virtual | ~huge_file () |
DEFINE_CLASS_NAME ("huge_file") | |
const basis::astring & | name () const |
returns the name of the file this operates on. More... | |
bool | good () const |
reports if the file was opened successfully. More... | |
bool | eof () const |
reports when the file pointer has reached the end of the file. More... | |
double | length () |
expensive operation accesses the file to find length. More... | |
double | file_pointer () const |
returns where we currently are in the file. More... | |
basis::outcome | seek (double new_position, byte_filer::origins origin=byte_filer::FROM_CURRENT) |
move the file pointer to "new_position" if possible. More... | |
basis::outcome | move_to (double absolute_posn) |
simpler seek just goes from current location to "absolute_posn". More... | |
basis::outcome | read (basis::byte_array &to_fill, int desired_size, int &size_read) |
reads "desired_size" into "to_fill" if possible. More... | |
basis::outcome | write (const basis::byte_array &to_write, int &size_written) |
stores the array "to_write" into the file. More... | |
bool | truncate () |
truncates the file after the current position. More... | |
basis::outcome | touch () |
void | flush () |
forces any pending writes to actually be saved to the file. More... | |
Supports reading and writing to very large files, > 4 gigabytes.
The standard file I/O functions only handle files up to 4 gigabytes. This class extends the range to essentially unlimited sizes, as long as the operating system can accurately do relative seeks and can read/write to files of the size needed.
Definition at line 35 of file huge_file.h.
Enumerator | |
---|---|
OKAY | |
FAILURE | |
ACCESS_DENIED | |
BAD_INPUT |
Definition at line 46 of file huge_file.h.
filesystem::huge_file::huge_file | ( | const basis::astring & | filename, |
const basis::astring & | permissions | ||
) |
opens "filename" for access, where it presumably is a very large file.
see byte filer for a description of the permissions.
Definition at line 40 of file huge_file.cpp.
|
virtual |
Definition at line 46 of file huge_file.cpp.
References basis::WHACK().
filesystem::huge_file::DEFINE_CLASS_NAME | ( | "huge_file" | ) |
bool filesystem::huge_file::eof | ( | ) | const |
reports when the file pointer has reached the end of the file.
Definition at line 183 of file huge_file.cpp.
References filesystem::byte_filer::eof().
Referenced by filesystem::heavy_file_operations::copy_file().
|
inline |
returns where we currently are in the file.
Definition at line 65 of file huge_file.h.
void filesystem::huge_file::flush | ( | ) |
forces any pending writes to actually be saved to the file.
Definition at line 53 of file huge_file.cpp.
References filesystem::byte_filer::flush().
bool filesystem::huge_file::good | ( | ) | const |
reports if the file was opened successfully.
Definition at line 181 of file huge_file.cpp.
References filesystem::byte_filer::good().
Referenced by filesystem::heavy_file_operations::buffer_files(), filesystem::file_info::calculate(), filesystem::heavy_file_operations::copy_file(), and filesystem::heavy_file_operations::write_file_chunk().
double filesystem::huge_file::length | ( | ) |
expensive operation accesses the file to find length.
Definition at line 57 of file huge_file.cpp.
References filesystem::byte_filer::eof(), filesystem::byte_filer::file_size_limit(), filesystem::byte_filer::FROM_CURRENT, filesystem::byte_filer::FROM_START, FUNCDEF, filesystem::byte_filer::length(), LOG, filesystem::byte_filer::name(), OKAY, filesystem::byte_filer::read(), seek(), and filesystem::byte_filer::seek().
Referenced by filesystem::heavy_file_operations::buffer_files(), filesystem::file_info::calculate(), seek(), and filesystem::heavy_file_operations::write_file_chunk().
outcome filesystem::huge_file::move_to | ( | double | absolute_posn | ) |
simpler seek just goes from current location to "absolute_posn".
Definition at line 185 of file huge_file.cpp.
References basis::absolute_value(), FAILURE, filesystem::byte_filer::file_size_limit(), filesystem::byte_filer::FROM_CURRENT, FUNCDEF, LOG, basis::minimum(), OKAY, and filesystem::byte_filer::seek().
Referenced by seek().
const astring & filesystem::huge_file::name | ( | ) | const |
returns the name of the file this operates on.
Definition at line 51 of file huge_file.cpp.
References filesystem::byte_filer::name().
outcome filesystem::huge_file::read | ( | basis::byte_array & | to_fill, |
int | desired_size, | ||
int & | size_read | ||
) |
reads "desired_size" into "to_fill" if possible.
"size_read" reports how many bytes were actually read.
Definition at line 263 of file huge_file.cpp.
References FAILURE, FUNCDEF, OKAY, and filesystem::byte_filer::read().
Referenced by filesystem::heavy_file_operations::buffer_files(), filesystem::file_info::calculate(), and filesystem::heavy_file_operations::copy_file().
outcome filesystem::huge_file::seek | ( | double | new_position, |
byte_filer::origins | origin = byte_filer::FROM_CURRENT |
||
) |
move the file pointer to "new_position" if possible.
the relative seek is the easiest type of seek to accomplish with a huge file. the other types are also supported, but take a bit more to implement.
Definition at line 231 of file huge_file.cpp.
References BAD_INPUT, FAILURE, filesystem::byte_filer::FROM_CURRENT, filesystem::byte_filer::FROM_END, filesystem::byte_filer::FROM_START, FUNCDEF, length(), LOG, move_to(), and filesystem::byte_filer::seek().
Referenced by filesystem::heavy_file_operations::buffer_files(), filesystem::file_info::calculate(), length(), and filesystem::heavy_file_operations::write_file_chunk().
basis::outcome filesystem::huge_file::touch | ( | ) |
Definition at line 287 of file huge_file.cpp.
References filesystem::filename::exists(), eml_to_txt::f, FAILURE, FUNCDEF, LOG, filesystem::byte_filer::name(), NULL_POINTER, basis::astring::observe(), OKAY, truncate(), and write().
Referenced by filesystem::heavy_file_operations::write_file_chunk().
bool filesystem::huge_file::truncate | ( | ) |
truncates the file after the current position.
Definition at line 55 of file huge_file.cpp.
References filesystem::byte_filer::truncate().
Referenced by touch(), and filesystem::heavy_file_operations::write_file_chunk().
outcome filesystem::huge_file::write | ( | const basis::byte_array & | to_write, |
int & | size_written | ||
) |
stores the array "to_write" into the file.
"size_written" reports how many bytes got written.
Definition at line 275 of file huge_file.cpp.
References FAILURE, FUNCDEF, OKAY, and filesystem::byte_filer::write().
Referenced by filesystem::heavy_file_operations::copy_file(), touch(), and filesystem::heavy_file_operations::write_file_chunk().