3 #ifndef __ARC_FILEINFO_H__ 4 #define __ARC_FILEINFO_H__ 9 #include <arc/DateTime.h> 11 #include <arc/StringConv.h> 39 size((unsigned long long int)(-1)),
40 modified((time_t)(-1)),
44 if (!name.empty()) metadata[
"name"] = name;
54 std::string::size_type pos = name.rfind(
'/');
55 if (pos != std::string::npos)
56 return name.substr(pos + 1);
79 return (size != (
unsigned long long int)(-1));
88 void SetSize(
const unsigned long long int s) {
95 return (!checksum.empty());
106 metadata[
"checksum"] = c;
111 return (modified != -1);
122 metadata[
"mtime"] = t.
str();
127 return (valid != -1);
138 metadata[
"validity"] = t.
str();
160 return (!latency.empty());
171 metadata[
"latency"] = l;
186 return (
lower(this->name).compare(
lower(f.name)) < 0);
190 operator bool()
const {
191 return !name.empty();
203 unsigned long long int size;
204 std::string checksum;
209 std::map<std::string, std::string> metadata;
214 #endif // __ARC_FILEINFO_H__ Arc namespace contains all core ARC classes.
Definition: ArcConfig.h:11
bool CheckType() const
Check if file type is known.
Definition: FileInfo.h:142
std::string str(const TimeFormat &=time_format) const
Returns a string representation of the time, using the specified format.
void SetType(const Type t)
Set file type.
Definition: FileInfo.h:152
unsigned long long int GetSize() const
Returns file size.
Definition: FileInfo.h:83
bool CheckCheckSum() const
Check if checksum is known.
Definition: FileInfo.h:94
void SetLatency(const std::string l)
Set access latency.
Definition: FileInfo.h:169
bool operator!() const
Returns true if file name is not defined.
Definition: FileInfo.h:195
A class for storing and manipulating times.
Definition: DateTime.h:125
void SetName(const std::string &n)
Set name of the file (file path).
Definition: FileInfo.h:62
std::string GetLatency() const
Returns access latency.
Definition: FileInfo.h:164
Type GetType() const
Returns file type.
Definition: FileInfo.h:147
bool operator<(const FileInfo &f) const
Returns true if this file's name is before f's name alphabetically.
Definition: FileInfo.h:185
void SetValid(const Time &t)
Set validity time.
Definition: FileInfo.h:136
void SetModified(const Time &t)
Set modified time.
Definition: FileInfo.h:120
bool CheckLatency() const
Check if access latency is known.
Definition: FileInfo.h:159
void AddURL(const URL &u)
Add a replica to this file.
Definition: FileInfo.h:73
std::string tostring(T t, int width=0, int precision=0)
This method converts any type to a string of the width given.
Definition: StringConv.h:92
const std::list< URL > & GetURLs() const
Returns the list of file replicas (for index services).
Definition: FileInfo.h:68
bool CheckModified() const
Check if modified time is known.
Definition: FileInfo.h:110
std::map< std::string, std::string > GetMetaData() const
Returns map of generic metadata.
Definition: FileInfo.h:175
bool CheckSize() const
Check if file size is known.
Definition: FileInfo.h:78
Unknown.
Definition: FileInfo.h:31
const std::string & GetCheckSum() const
Returns checksum.
Definition: FileInfo.h:99
Time GetValid() const
Returns validity time.
Definition: FileInfo.h:131
Time GetModified() const
Returns modified time.
Definition: FileInfo.h:115
std::string GetLastName() const
Returns the last component of the file name (like the "basename" command).
Definition: FileInfo.h:53
Class to represent general URLs.
Definition: URL.h:88
std::string lower(const std::string &s)
This method converts the given string to lower case.
void SetSize(const unsigned long long int s)
Set file size.
Definition: FileInfo.h:88
Type
Type of file object.
Definition: FileInfo.h:30
bool CheckValid() const
Check if validity time is known.
Definition: FileInfo.h:126
void SetMetaData(const std::string att, const std::string val)
Set an attribute of generic metadata.
Definition: FileInfo.h:180
FileInfo stores information about files (metadata).
Definition: FileInfo.h:25
const std::string & GetName() const
Returns the name (file path) of the file.
Definition: FileInfo.h:48
FileInfo(const std::string &name="")
Construct a new FileInfo with optional name (file path).
Definition: FileInfo.h:37
void SetCheckSum(const std::string &c)
Set checksum.
Definition: FileInfo.h:104
File-type.
Definition: FileInfo.h:32
Directory-type.
Definition: FileInfo.h:33