filesystem::huge_file Class Reference

Supports reading and writing to very large files, > 4 gigabytes. More...

#include <huge_file.h>

Collaboration diagram for filesystem::huge_file:
Collaboration graph
[legend]

List of all members.

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.
virtual ~huge_file ()
 DEFINE_CLASS_NAME ("huge_file")
bool good () const
 reports if the file was opened successfully.
bool eof () const
 reports when the file pointer has reached the end of the file.
double length ()
 expensive operation accesses the file to find length.
double file_pointer () const
 returns where we currently are in the file.
basis::outcome seek (double new_position, byte_filer::origins origin=byte_filer::FROM_CURRENT)
 move the file pointer to "new_position" if possible.
basis::outcome move_to (double absolute_posn)
 simpler seek just goes from current location to "absolute_posn".
basis::outcome read (basis::byte_array &to_fill, int desired_size, int &size_read)
 reads "desired_size" into "to_fill" if possible.
basis::outcome write (const basis::byte_array &to_write, int &size_written)
 stores the array "to_write" into the file.
bool truncate ()
 truncates the file after the current position.
void flush ()
 forces any pending writes to actually be saved to the file.

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

Enumerator:
OKAY 
FAILURE 
ACCESS_DENIED 
BAD_INPUT 

Definition at line 46 of file huge_file.h.


Constructor & Destructor Documentation

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 34 of file huge_file.cpp.

filesystem::huge_file::~huge_file (  )  [virtual]

Definition at line 40 of file huge_file.cpp.

References basis::WHACK().


Member Function Documentation

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 175 of file huge_file.cpp.

References filesystem::byte_filer::eof().

Referenced by filesystem::heavy_file_operations::copy_file().

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

returns where we currently are in the file.

Definition at line 62 of file huge_file.h.

void filesystem::huge_file::flush (  ) 

forces any pending writes to actually be saved to the file.

Definition at line 45 of file huge_file.cpp.

References filesystem::byte_filer::flush().

bool filesystem::huge_file::good (  )  const
double filesystem::huge_file::length (  ) 
outcome filesystem::huge_file::move_to ( double  absolute_posn  ) 

simpler seek just goes from current location to "absolute_posn".

Definition at line 177 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().

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 255 of file huge_file.cpp.

References FAILURE, OKAY, and filesystem::byte_filer::read().

Referenced by filesystem::heavy_file_operations::buffer_files(), 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 223 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(), length(), and filesystem::heavy_file_operations::write_file_chunk().

bool filesystem::huge_file::truncate (  ) 

truncates the file after the current position.

Definition at line 47 of file huge_file.cpp.

References filesystem::byte_filer::truncate().

Referenced by 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 267 of file huge_file.cpp.

References FAILURE, OKAY, and filesystem::byte_filer::write().

Referenced by filesystem::heavy_file_operations::copy_file(), and filesystem::heavy_file_operations::write_file_chunk().


The documentation for this class was generated from the following files:
Generated on Sat Jan 28 04:25:33 2012 for hoople2 project by  doxygen 1.6.3