feisty meow concerns codebase
2.140
|
Provides serious file operations, such as copy and partial writing. More...
#include <heavy_file_ops.h>
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... | |
Provides serious file operations, such as copy and partial writing.
Definition at line 59 of file heavy_file_ops.h.
Enumerator | |
---|---|
OKAY | |
BAD_INPUT | |
FINISHED | |
DEFINE_OUTCOME | |
DEFINE_OUTCOME | |
DEFINE_OUTCOME |
Definition at line 64 of file heavy_file_ops.h.
|
virtual |
Definition at line 106 of file heavy_file_ops.cpp.
|
static |
reads files in "to_transfer" and packs them into a "storage" buffer.
the maximum size allowed in storage is "maximum_bytes". the record of the last file piece stored in "last_action" allows the next chunk to be sent in subsequent calls. note that the buffer "storage" is cleared out before bytes are stored into it; this is not an additive operation.
Definition at line 238 of file heavy_file_ops.cpp.
References filesystem::file_transfer_header::_byte_start, filesystem::file_transfer_header::_filename, filesystem::file_transfer_header::_length, filesystem::file_info::_time, filesystem::file_transfer_header::_time, BAD_INPUT, structures::amorph< contents >::elements(), filesystem::filename_list::find(), FINISHED, filesystem::byte_filer::FROM_START, FUNCDEF, structures::amorph< contents >::get(), filesystem::huge_file::good(), filesystem::huge_file::length(), basis::array< contents >::length(), LOG, basis::minimum(), filesystem::MINIMUM_ARRAY_SIZE, OKAY, filesystem::file_transfer_header::pack(), filesystem::file_transfer_header::packed_size(), filesystem::filename::raw(), filesystem::huge_file::read(), basis::array< contents >::reset(), and filesystem::huge_file::seek().
|
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().
|
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().
filesystem::heavy_file_operations::DEFINE_CLASS_NAME | ( | "heavy_file_operations" | ) |
|
static |
Definition at line 109 of file heavy_file_ops.cpp.
References basis::outcome::value().
|
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().
|
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().