X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Ffilesystem%2Fhuge_file.cpp;h=bdc1522835e1a3956a6c5476ceb91d858b44f824;hb=26e2a15bc99ae049324df5b61beb9e9ae17300d0;hp=33b4672a2f23f50d3cbe81324e5719c02a5c32d1;hpb=5efbb79c4a7e11ff2d7193b2cea13fdc79230580;p=feisty_meow.git diff --git a/nucleus/library/filesystem/huge_file.cpp b/nucleus/library/filesystem/huge_file.cpp index 33b4672a..bdc15228 100644 --- a/nucleus/library/filesystem/huge_file.cpp +++ b/nucleus/library/filesystem/huge_file.cpp @@ -20,6 +20,7 @@ #include #include +#include #undef LOG #define LOG(to_print) printf("%s::%s: %s\n", static_class_name(), func, astring(to_print).s()) @@ -276,5 +277,24 @@ outcome huge_file::write(const byte_array &to_write, int &size_written) return OKAY; } +basis::outcome huge_file::touch() +{ + if (filename(_real_file->name()).exists()) { + // file exists, so just update time. + int ret = utimes(_real_file->name().observe(), NIL); + if (ret != 0) + return FAILURE; + } else { + // file doesn't exist yet. + byte_array junk(1); + int written; + outcome ret = write(junk, written); + if (ret != OKAY) ret; + if (!truncate()) + return FAILURE; + } + return OKAY; +} + } //namespace.