X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Ffilesystem%2Fheavy_file_ops.cpp;h=3ddd76648930cee349a1d8f2b6dd467bd19ca7af;hb=0fa7b30df320a093cd6ac3b0231652e3322058d2;hp=1e63ba318f846d5cb899c79f841a1fe31e7028cf;hpb=457b128b77b5b4a0b7dd3094de543de2ce1477ad;p=feisty_meow.git diff --git a/nucleus/library/filesystem/heavy_file_ops.cpp b/nucleus/library/filesystem/heavy_file_ops.cpp index 1e63ba31..3ddd7664 100644 --- a/nucleus/library/filesystem/heavy_file_ops.cpp +++ b/nucleus/library/filesystem/heavy_file_ops.cpp @@ -27,7 +27,7 @@ using namespace structures; namespace filesystem { -//#define DEBUG_HEAVY_FILE_OPS +#define DEBUG_HEAVY_FILE_OPS // uncomment for noisier debugging. #undef LOG @@ -208,15 +208,13 @@ outcome heavy_file_operations::write_file_chunk(const astring &target, return OKAY; } -bool heavy_file_operations::advance(const filename_list &to_transfer, +basis::outcome heavy_file_operations::advance(const filename_list &to_transfer, file_transfer_header &last_action) { -#ifdef DEBUG_HEAVY_FILE_OPS FUNCDEF("advance"); -#endif int indy = to_transfer.locate(last_action._filename); - if (negative(indy)) return false; // error. - if (indy == to_transfer.elements() - 1) return false; // done. + if (negative(indy)) return BAD_INPUT; // error, file not found in list. + if (indy >= to_transfer.elements() - 1) return FINISHED; // done. const file_info *currfile = to_transfer.get(indy + 1); last_action._filename = currfile->raw(); last_action._time = currfile->_time; @@ -228,21 +226,19 @@ bool heavy_file_operations::advance(const filename_list &to_transfer, last_action._byte_start = 0; last_action._length = 0; - return true; + return OKAY; } outcome heavy_file_operations::buffer_files(const astring &source_root, const filename_list &to_transfer, file_transfer_header &last_action, byte_array &storage, int maximum_bytes) { -#ifdef DEBUG_HEAVY_FILE_OPS -// FUNCDEF("buffer_files"); -#endif + FUNCDEF("buffer_files"); storage.reset(); // clear out the current contents. if (!to_transfer.elements()) { // we seem to be done. - return OKAY; + return FINISHED; } outcome to_return = OKAY; @@ -277,14 +273,17 @@ outcome heavy_file_operations::buffer_files(const astring &source_root, huge_file current(full_file, "rb"); if (!current.good()) { // we need to skip this file. - if (!advance(to_transfer, last_action)) break; +LOG(astring("skipping bad file: ") + full_file); + to_return = advance(to_transfer, last_action); + if (to_return != OKAY) break; continue; } - if ((last_action._byte_start + last_action._length >= current.length()) - && current.length()) { + if (last_action._byte_start + last_action._length >= current.length()) { +LOG(astring("finished stuffing file: ") + full_file); // this file is done now. go to the next one. - if (!advance(to_transfer, last_action)) break; + to_return = advance(to_transfer, last_action); + if (to_return != OKAY) break; continue; } @@ -303,7 +302,8 @@ outcome heavy_file_operations::buffer_files(const astring &source_root, if (bytes_read != new_len) { if (!bytes_read) { // some kind of problem reading the file. - if (!advance(to_transfer, last_action)) break; + to_return = advance(to_transfer, last_action); + if (to_return != OKAY) break; continue; } //why would this happen? just complain, i guess. @@ -320,7 +320,8 @@ outcome heavy_file_operations::buffer_files(const astring &source_root, if (!current.length()) { // ensure we don't get stuck redoing zero length files, which we allowed // to go past their end above (since otherwise we'd never see them). - if (!advance(to_transfer, last_action)) break; + to_return = advance(to_transfer, last_action); + if (to_return != OKAY) break; continue; }