feisty meow concerns codebase  2.140
filesystem::huge_file Class Reference

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::astringname () 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...
 

Detailed Description

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.

Member Enumeration Documentation

◆ outcomes

Enumerator
OKAY 
FAILURE 
ACCESS_DENIED 
BAD_INPUT 

Definition at line 46 of file huge_file.h.

Constructor & Destructor Documentation

◆ huge_file()

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.

◆ ~huge_file()

filesystem::huge_file::~huge_file ( )
virtual

Definition at line 46 of file huge_file.cpp.

References basis::WHACK().

Member Function Documentation

◆ DEFINE_CLASS_NAME()

filesystem::huge_file::DEFINE_CLASS_NAME ( "huge_file"  )

◆ eof()

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().

◆ file_pointer()

double filesystem::huge_file::file_pointer ( ) const
inline

returns where we currently are in the file.

Definition at line 65 of file huge_file.h.

◆ flush()

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().

◆ good()

bool filesystem::huge_file::good ( ) const

◆ length()

◆ move_to()

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().

◆ name()

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().

◆ read()

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().

◆ seek()

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().

◆ touch()

◆ truncate()

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().

◆ write()

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().


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