00001 #ifndef HEAVY_FILE_OPERATIONS_CLASS
00002 #define HEAVY_FILE_OPERATIONS_CLASS
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "opsysdll.h"
00019
00020 #include <basis/object_base.h>
00021 #include <basis/packable.h>
00022
00023
00024 class file_transfer_header;
00025 class filename_list;
00026
00028
00029 class OPSYSTEM_CLASS_STYLE heavy_file_operations
00030 {
00031 public:
00032 virtual ~heavy_file_operations();
00033
00034 enum outcomes {
00035 OKAY = common::OKAY,
00036 BAD_INPUT = common::BAD_INPUT,
00037
00038
00039
00040
00041 DEFINE_OUTCOME(SOURCE_MISSING, -47, "The source file is not accessible"),
00042 DEFINE_OUTCOME(TARGET_DIR_ERROR, -48, "The target's directory could not "
00043 "be created"),
00044 DEFINE_OUTCOME(TARGET_ACCESS_ERROR, -49, "The target file could not be "
00045 "created")
00046 };
00047 static const char *outcome_name(const outcome &to_name);
00048
00049 IMPLEMENT_CLASS_NAME("heavy_file_operations");
00050
00051 static const size_t COPY_CHUNK_FACTOR;
00053 static const size_t copy_chunk_factor();
00055
00056 static outcome copy_file(const istring &source, const istring &destination,
00057 int copy_chunk_factor = copy_chunk_factor());
00059
00062
00063
00064
00065
00067
00071 static outcome write_file_chunk(const istring &target, double byte_start,
00072 const byte_array &chunk, bool truncate = true,
00073 int copy_chunk_factor = copy_chunk_factor());
00075
00083 static outcome buffer_files(const istring &source_root,
00084 const filename_list &to_transfer, file_transfer_header &last_action,
00085 byte_array &storage, int maximum_bytes);
00087
00091 };
00092
00094
00096
00099 class OPSYSTEM_CLASS_STYLE file_transfer_header : public packable
00100 {
00101 public:
00102 istring _filename;
00103 double _byte_start;
00104 int _length;
00105
00106 file_transfer_header();
00107
00108 virtual void pack(byte_array &packed_form) const;
00109 virtual bool unpack(byte_array &packed_form);
00110
00111 virtual int packed_size() const;
00112
00113 istring text_form() const;
00114 };
00115
00116 #endif
00117