feisty meow concerns codebase  2.140
filesystem::heavy_file_operations Class Reference

Provides serious file operations, such as copy and partial writing. More...

#include <heavy_file_ops.h>

Inheritance diagram for filesystem::heavy_file_operations:
Collaboration diagram for filesystem::heavy_file_operations:

Public Types

enum  outcomes {
  OKAY = basis::common::OKAY , BAD_INPUT = basis::common::BAD_INPUT , FINISHED = basis::common::IS_EMPTY , DEFINE_OUTCOME =(SOURCE_MISSING, -43, "The source file is not accessible") ,
  DEFINE_OUTCOME =(SOURCE_MISSING, -43, "The source file is not accessible") , DEFINE_OUTCOME =(SOURCE_MISSING, -43, "The source file is not accessible")
}
 

Public Member Functions

virtual ~heavy_file_operations ()
 
 DEFINE_CLASS_NAME ("heavy_file_operations")
 

Static Public Member Functions

static const char * outcome_name (const basis::outcome &to_name)
 
static size_t copy_chunk_factor ()
 method can be exported for use by shared libs. More...
 
static basis::outcome copy_file (const basis::astring &source, const basis::astring &destination, int copy_chunk_factor=heavy_file_operations::copy_chunk_factor())
 copies a file from the "source" location to the "destination". More...
 
static basis::outcome write_file_chunk (const basis::astring &target, double byte_start, const basis::byte_array &chunk, bool truncate=true, int copy_chunk_factor=heavy_file_operations::copy_chunk_factor())
 stores a chunk of bytes into the "target" file. More...
 
static basis::outcome buffer_files (const basis::astring &source_root, const filename_list &to_transfer, file_transfer_header &last_action, basis::byte_array &storage, int maximum_bytes)
 reads files in "to_transfer" and packs them into a "storage" buffer. More...
 

Static Public Attributes

static const size_t COPY_CHUNK_FACTOR = 1 * MEGABYTE
 the default copy chunk size for the file copy method. More...
 

Detailed Description

Provides serious file operations, such as copy and partial writing.

Definition at line 59 of file heavy_file_ops.h.

Member Enumeration Documentation

◆ outcomes

Enumerator
OKAY 
BAD_INPUT 
FINISHED 
DEFINE_OUTCOME 
DEFINE_OUTCOME 
DEFINE_OUTCOME 

Definition at line 64 of file heavy_file_ops.h.

Constructor & Destructor Documentation

◆ ~heavy_file_operations()

filesystem::heavy_file_operations::~heavy_file_operations ( )
virtual

Definition at line 106 of file heavy_file_ops.cpp.

Member Function Documentation

◆ buffer_files()

outcome filesystem::heavy_file_operations::buffer_files ( const basis::astring source_root,
const filename_list to_transfer,
file_transfer_header last_action,
basis::byte_array storage,
int  maximum_bytes 
)
static

◆ copy_chunk_factor()

size_t filesystem::heavy_file_operations::copy_chunk_factor ( )
static

method can be exported for use by shared libs.

Definition at line 103 of file heavy_file_ops.cpp.

References COPY_CHUNK_FACTOR.

Referenced by copy_file(), and write_file_chunk().

◆ copy_file()

outcome filesystem::heavy_file_operations::copy_file ( const basis::astring source,
const basis::astring destination,
int  copy_chunk_factor = heavy_file_operations::copy_chunk_factor() 
)
static

copies a file from the "source" location to the "destination".

the outcomes could be from this class or from common::outcomes. the "copy_chunk_factor" is the read buffer size to use while copying.

Definition at line 119 of file heavy_file_ops.cpp.

References copy_chunk_factor(), filesystem::filename::dirname(), filesystem::huge_file::eof(), filesystem::filename::exists(), FUNCDEF, filesystem::huge_file::good(), LOG, OKAY, filesystem::huge_file::OKAY, filesystem::filename::raw(), filesystem::huge_file::read(), filesystem::directory::recursive_create(), filesystem::file_time::set_time(), filesystem::file_time::text_form(), and filesystem::huge_file::write().

◆ DEFINE_CLASS_NAME()

filesystem::heavy_file_operations::DEFINE_CLASS_NAME ( "heavy_file_operations"  )

◆ outcome_name()

const char * filesystem::heavy_file_operations::outcome_name ( const basis::outcome to_name)
static

Definition at line 109 of file heavy_file_ops.cpp.

References basis::outcome::value().

◆ write_file_chunk()

outcome filesystem::heavy_file_operations::write_file_chunk ( const basis::astring target,
double  byte_start,
const basis::byte_array chunk,
bool  truncate = true,
int  copy_chunk_factor = heavy_file_operations::copy_chunk_factor() 
)
static

stores a chunk of bytes into the "target" file.

writes the content stored in "chunk" into the file "target" at the position "byte_start". the entire "chunk" will be used, which means the file will either be that much larger or have the space between byte_start and (byte_start + chunk.length() - 1) replaced. if the file is not yet as large as "byte_start", then it will be expanded appropriately. if "truncate" is true, then any contents past the new chunk are dropped from the file.

Definition at line 167 of file heavy_file_ops.cpp.

References BAD_INPUT, copy_chunk_factor(), filesystem::filename::dirname(), filesystem::filename::exists(), filesystem::byte_filer::FROM_END, filesystem::byte_filer::FROM_START, FUNCDEF, filesystem::huge_file::good(), filesystem::huge_file::length(), basis::array< contents >::length(), LOG, basis::minimum(), OKAY, filesystem::filename::raw(), filesystem::directory::recursive_create(), basis::array< contents >::reset(), filesystem::huge_file::seek(), filesystem::huge_file::touch(), filesystem::huge_file::truncate(), and filesystem::huge_file::write().

Member Data Documentation

◆ COPY_CHUNK_FACTOR

const size_t filesystem::heavy_file_operations::COPY_CHUNK_FACTOR = 1 * MEGABYTE
static

the default copy chunk size for the file copy method.

Definition at line 78 of file heavy_file_ops.h.

Referenced by copy_chunk_factor().


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