Add support function get_real_time()

This commit is contained in:
Ingo Weinhold 2011-06-24 01:42:26 +02:00
parent a2fc40be04
commit 05d7d4818e
2 changed files with 15 additions and 4 deletions

View File

@ -10,6 +10,7 @@
#include "EmptyAttributeDirectoryCookie.h" #include "EmptyAttributeDirectoryCookie.h"
#include "DebugSupport.h" #include "DebugSupport.h"
#include "Utils.h"
PackageLinksDirectory::PackageLinksDirectory() PackageLinksDirectory::PackageLinksDirectory()
@ -17,10 +18,7 @@ PackageLinksDirectory::PackageLinksDirectory()
Directory(0) Directory(0)
// the ID needs to be assigned later, when added to a volume // the ID needs to be assigned later, when added to a volume
{ {
bigtime_t timeMicros = real_time_clock_usecs(); get_real_time(fModifiedTime);
fModifiedTime.tv_sec = timeMicros / 1000000;
fModifiedTime.tv_nsec = (timeMicros % 1000000) * 1000;
} }

View File

@ -8,6 +8,9 @@
#include <dirent.h> #include <dirent.h>
#include <string.h> #include <string.h>
#include <time.h>
#include <OS.h>
inline bool operator<(const timespec& a, const timespec& b) inline bool operator<(const timespec& a, const timespec& b)
@ -38,4 +41,14 @@ set_dirent_name(struct dirent* buffer, size_t bufferSize, const char* name,
} }
static inline void
get_real_time(timespec& time)
{
bigtime_t timeMicros = real_time_clock_usecs();
time.tv_sec = timeMicros / 1000000;
time.tv_nsec = (timeMicros % 1000000) * 1000;
}
#endif // UTILS_H #endif // UTILS_H