Nebula
Loading...
Searching...
No Matches
posixfiletime.h
Go to the documentation of this file.
1#pragma once
2#ifndef POSIX_POSIXFILETIME_H
3#define POSIX_POSIXFILETIME_H
4//------------------------------------------------------------------------------
13#include "core/types.h"
14
15//------------------------------------------------------------------------------
16namespace Posix
17{
19{
20public:
24 PosixFileTime(const Util::String& str);
26 friend bool operator==(const PosixFileTime& a, const PosixFileTime& b);
28 friend bool operator!=(const PosixFileTime& a, const PosixFileTime& b);
30 friend bool operator>(const PosixFileTime& a, const PosixFileTime& b);
32 friend bool operator<(const PosixFileTime& a, const PosixFileTime& b);
33
35 uint GetHighBits() const;
37 uint GetLowBits() const;
39 void SetBits(uint lowbits, uint highbits);
40
42 Util::String AsString() const;
43
44private:
45 friend class PosixFSWrapper;
46 friend class PosixCalendarTime;
47
48 timespec time;
49};
50
51//------------------------------------------------------------------------------
54inline
56{
57 time.tv_sec = 0;
58 time.tv_nsec = 0;
59}
60
61//------------------------------------------------------------------------------
64inline uint
66{
67 return this->time.tv_sec;
68}
69
70//------------------------------------------------------------------------------
73inline uint
75{
76 return this->time.tv_nsec;
77}
78
79//------------------------------------------------------------------------------
82inline void
84{
85 this->time.tv_nsec = lowbits;
86 this->time.tv_sec = highbits;
87}
88//------------------------------------------------------------------------------
91inline bool
93{
94 return (a.time.tv_sec == b.time.tv_sec) && (a.time.tv_nsec == b.time.tv_nsec);
95}
96
97//------------------------------------------------------------------------------
100inline bool
102{
103 return (a.time.tv_sec != b.time.tv_sec) || (a.time.tv_nsec != b.time.tv_nsec);
104}
105
106//------------------------------------------------------------------------------
109inline bool
111{
112 if (a.time.tv_sec < b.time.tv_sec) return false;
113 if (a.time.tv_sec > b.time.tv_sec) return true;
114 if (a.time.tv_nsec > b.time.tv_nsec) return true;
115 return false;
116}
117
118//------------------------------------------------------------------------------
121inline bool
122operator <(const PosixFileTime& a, const PosixFileTime& b)
123{
124 if (a.time.tv_sec > b.time.tv_sec) return false;
125 if (a.time.tv_sec < b.time.tv_sec) return true;
126 if (a.time.tv_nsec < b.time.tv_nsec) return true;
127 return false;
128}
129
130}; // namespace Posix
131//------------------------------------------------------------------------------
132#endif
133
Posix implementation of CalendarTime.
Definition posixcalendartime.h:20
Internal filesystem wrapper for Posix.
Definition posixfswrapper.h:24
Implements a Posix-specific file-access time stamp.
Definition posixfiletime.h:19
uint GetLowBits() const
get log bits of internal time structure (resolution is platform dependent!)
Definition posixfiletime.h:74
void SetBits(uint lowbits, uint highbits)
set both parts of time (platform dependent)
Definition posixfiletime.h:83
friend bool operator<(const PosixFileTime &a, const PosixFileTime &b)
operator <
Definition posixfiletime.h:122
uint GetHighBits() const
get high bits of internal time structure (resolution is platform dependent!)
Definition posixfiletime.h:65
friend bool operator>(const PosixFileTime &a, const PosixFileTime &b)
operator >
Definition posixfiletime.h:110
friend bool operator!=(const PosixFileTime &a, const PosixFileTime &b)
operator !=
Definition posixfiletime.h:101
timespec time
Definition posixfiletime.h:48
PosixFileTime()
constructor
Definition posixfiletime.h:55
friend bool operator==(const PosixFileTime &a, const PosixFileTime &b)
operator ==
Definition posixfiletime.h:92
Util::String AsString() const
convert to string
Definition posixfiletime.cc:25
Posix implemention of a read-many write-few lock.
Definition posixsysfunc.cc:21
bool operator==(const PosixFileTime &a, const PosixFileTime &b)
Definition posixfiletime.h:92
bool operator>(const PosixFileTime &a, const PosixFileTime &b)
Definition posixfiletime.h:110
bool operator<(const PosixFileTime &a, const PosixFileTime &b)
Definition posixfiletime.h:122
bool operator!=(const PosixFileTime &a, const PosixFileTime &b)
Definition posixfiletime.h:101
Nebula's universal string class.
Definition string.h:50
unsigned int uint
Definition types.h:31