25 #include <sys/types.h>
31 #include <sys/utime.h>
35 #define LOG(to_print) printf("%s::%s: %s\n", static_class_name(), func, astring(to_print).s())
37 using namespace basis;
41 file_time::file_time() : _when(0) {
reset(
""); }
63 held_time.actime =
raw();
64 held_time.modtime =
raw();
84 FILE *the_file = (FILE *)the_FILE_in;
88 struct stat stat_buffer;
90 LOG(
"stat failure on file");
92 _when = stat_buffer.st_mtime;
95 int file_time::compare(
const file_time &b)
const
97 if (_when > b._when)
return 1;
98 else if (_when == b._when)
return 0;
105 if (!cast)
return false;
106 return bool(compare(*cast) < 0);
112 if (!cast)
return false;
113 return bool(compare(*cast) == 0);
123 tm *
now = localtime(&_when);
125 now->tm_year+1900,
now->tm_mon+1,
now->tm_mday,
now->tm_hour,
now->tm_min,
now->tm_sec));
140 if (!tempo.
unpack(packed_form))
return false;
a_sprintf is a specialization of astring that provides printf style support.
Provides a dynamically resizable ASCII character string.
const char * s() const
synonym for observe. the 's' stands for "string", if that helps.
void pack(byte_array &target) const
stores this string in the "target". it can later be unpacked again.
int convert(int default_value) const
Converts the string into a corresponding integer.
bool unpack(byte_array &source)
retrieves a string (packed with pack()) from "source" into this string.
Defines the base class for all string processing objects in hoople.
virtual base_string & assign(const base_string &s)=0
Sets the contents of this string to "s".
A very common template for a dynamic array of bytes.
Base class for object that can tell itself apart from other instances.
A base for objects that can be alphabetically (lexicographically) ordered.
virtual const char * class_name() const =0
Returns the bare name of this class as a constant character pointer.
bool set_time(const basis::astring &filename)
sets the time for the the "filename" to the currently held time.
virtual bool equal_to(const basis::equalizable &ft2) const
virtual bool less_than(const basis::orderable &ft2) const
virtual int packed_size() const
virtual void pack(basis::byte_array &packed_form) const
virtual void text_form(basis::base_string &time_string) const
returns a definitive but sorta ugly version of the file's time.
void reset(FILE *the_FILE)
reacquires the time from a different FILE than constructed with.
time_t raw() const
provides the OS version of the file's timestamp.
virtual void readable_text_form(basis::base_string &time_string) const
sets "time_string" to a human readable form of the file's time.
virtual bool unpack(basis::byte_array &packed_form)
file_time()
sets up a bogus file_time object.
Provides operations commonly needed on file names.
#define FUNCDEF(func_in)
FUNCDEF sets the name of a function (and plugs it into the callstack).
The guards collection helps in testing preconditions and reporting errors.
A platform independent way to obtain the timestamp of a file.
time_locus now()
returns our current locus in the time continuum.