if (add_it && !fnmatch(_pattern->s(), file, 0)) {
filename temp_name(*_path, file);
if (!temp_name.is_normal()) {
-#ifdef DEBUG_DIRECTORY
+//#ifdef DEBUG_DIRECTORY
LOG(astring("skipping abnormal file: ") + temp_name);
-#endif
+//#endif
entry = readdir(dir);
continue; // cannot be adding goofy named pipes etc; cannot manage those.
}
bool skip_tail = false; // true if we don't need the tail piece.
double head_start = 0, head_end = 0, tail_start = 0,
tail_end = _file_size - 1;
- if (_file_size <= double(2 * checksum_edge)) {
+ if (_file_size == 0) {
+ head_end = 0;
+ skip_tail = true;
+ } else if (_file_size <= double(2 * checksum_edge)) {
// we're applying a rule for when the file is too small compared to
// the chunk factor doubled; we'll just read the whole file.
head_end = _file_size - 1;
void file_info::pack(byte_array &packed_form) const
{
+ FUNCDEF("pack");
filename::pack(packed_form);
attach(packed_form, _file_size);
_time.pack(packed_form);
{
if (is_directory())
return true;
+ // if the file name is empty, that cannot exist.
if (!length())
return false;
return is_readable();
-/// byte_filer opened(observe(), "rb");
-/// return opened.good();
}
bool filename::legal_character(char to_check)
// open the file for updating (either read or write).
if (!target_file.good()) return TARGET_ACCESS_ERROR;
double curr_len = target_file.length();
+ target_file.touch();
if (curr_len < byte_start) {
byte_array new_chunk;
#include <basis/guards.h>
#include <stdio.h>
+#include <sys/time.h>
#undef LOG
#define LOG(to_print) printf("%s::%s: %s\n", static_class_name(), func, astring(to_print).s())
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.
bool truncate();
//!< truncates the file after the current position.
+ basis::outcome touch();
+ //<! creates the file if it doesn't exist, or updates the time on the file.
+
void flush();
//!< forces any pending writes to actually be saved to the file.