heavy_file_ops.h

Go to the documentation of this file.
00001 #ifndef HEAVY_FILE_OPERATIONS_CLASS
00002 #define HEAVY_FILE_OPERATIONS_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : heavy file operations                                             *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 2005-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "opsysdll.h"
00019 
00020 #include <basis/object_base.h>
00021 #include <basis/packable.h>
00022 
00023 // forward.
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 //    GARBAGE = common::GARBAGE,
00038 //    NOT_FOUND = common::NOT_FOUND,
00039 //    NONE_READY = common::NONE_READY,
00040 //    FAILURE = common::FAILURE,
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 //can't live here due to use of tentacles.
00063 /*  static outcome copy_hierarchy(const istring &source_dir,
00064           const istring &target_dir,
00065           const istring &source_start = istring::empty_string()); */
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 

Generated on Fri Nov 28 04:29:25 2008 for HOOPLE Libraries by  doxygen 1.5.1