/usr/include/arc/data/FileInfo.h is in nordugrid-arc-dev 5.0.5-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | // -*- indent-tabs-mode: nil -*-
#ifndef __ARC_FILEINFO_H__
#define __ARC_FILEINFO_H__
#include <list>
#include <string>
#include <arc/DateTime.h>
#include <arc/URL.h>
#include <arc/StringConv.h>
namespace Arc {
/// FileInfo stores information about files (metadata).
/**
* Set/Get methods exist for "standard" metadata such as name, size and
* modification time, and there is a generic key-value map for
* protocol-specific attributes. The Set methods always set the corresponding
* entry in the generic map, so there is no need for a caller make two calls,
* for example SetSize(1) followed by SetMetaData("size", "1").
* \ingroup data
* \headerfile FileInfo.h arc/data/FileInfo.h
*/
class FileInfo {
public:
/// Type of file object.
enum Type {
file_type_unknown = 0, ///< Unknown
file_type_file = 1, ///< File-type
file_type_dir = 2 ///< Directory-type
};
/// Construct a new FileInfo with optional name (file path).
FileInfo(const std::string& name = "")
: name(name),
size((unsigned long long int)(-1)),
modified((time_t)(-1)),
valid((time_t)(-1)),
type(file_type_unknown),
latency("") {
if (!name.empty()) metadata["name"] = name;
}
/// Returns the name (file path) of the file.
const std::string& GetName() const {
return name;
}
/// Returns the last component of the file name (like the "basename" command).
std::string GetLastName() const {
std::string::size_type pos = name.rfind('/');
if (pos != std::string::npos)
return name.substr(pos + 1);
else
return name;
}
/// Set name of the file (file path).
void SetName(const std::string& n) {
name = n;
metadata["name"] = n;
}
/// Returns the list of file replicas (for index services).
const std::list<URL>& GetURLs() const {
return urls;
}
/// Add a replica to this file.
void AddURL(const URL& u) {
urls.push_back(u);
}
/// Check if file size is known.
bool CheckSize() const {
return (size != (unsigned long long int)(-1));
}
/// Returns file size.
unsigned long long int GetSize() const {
return size;
}
/// Set file size.
void SetSize(const unsigned long long int s) {
size = s;
metadata["size"] = tostring(s);
}
/// Check if checksum is known.
bool CheckCheckSum() const {
return (!checksum.empty());
}
/// Returns checksum.
const std::string& GetCheckSum() const {
return checksum;
}
/// Set checksum.
void SetCheckSum(const std::string& c) {
checksum = c;
metadata["checksum"] = c;
}
/// Check if modified time is known.
bool CheckModified() const {
return (modified != -1);
}
/// Returns modified time.
Time GetModified() const {
return modified;
}
/// Set modified time.
void SetModified(const Time& t) {
modified = t;
metadata["mtime"] = t.str();
}
/// Check if validity time is known.
bool CheckValid() const {
return (valid != -1);
}
/// Returns validity time.
Time GetValid() const {
return valid;
}
/// Set validity time.
void SetValid(const Time& t) {
valid = t;
metadata["validity"] = t.str();
}
/// Check if file type is known.
bool CheckType() const {
return (type != file_type_unknown);
}
/// Returns file type.
Type GetType() const {
return type;
}
/// Set file type.
void SetType(const Type t) {
type = t;
if (t == file_type_file) metadata["type"] = "file";
else if (t == file_type_dir) metadata["type"] = "dir";
}
/// Check if access latency is known.
bool CheckLatency() const {
return (!latency.empty());
}
/// Returns access latency.
std::string GetLatency() const {
return latency;
}
/// Set access latency.
void SetLatency(const std::string l) {
latency = l;
metadata["latency"] = l;
}
/// Returns map of generic metadata.
std::map<std::string, std::string> GetMetaData() const {
return metadata;
}
/// Set an attribute of generic metadata.
void SetMetaData(const std::string att, const std::string val) {
metadata[att] = val;
}
/// Returns true if this file's name is before f's name alphabetically.
bool operator<(const FileInfo& f) const {
return (lower(this->name).compare(lower(f.name)) < 0);
}
/// Returns true if file name is defined.
operator bool() const {
return !name.empty();
}
/// Returns true if file name is not defined.
bool operator!() const {
return name.empty();
}
private:
std::string name;
std::list<URL> urls; // Physical enpoints/URLs.
unsigned long long int size; // Size of file in bytes.
std::string checksum; // Checksum of file.
Time modified; // Creation/modification time.
Time valid; // Valid till time.
Type type; // File type - usually file_type_file
std::string latency; // Access latenct of file (applies to SRM only)
std::map<std::string, std::string> metadata; // Generic metadata attribute-value pairs
};
} // namespace Arc
#endif // __ARC_FILEINFO_H__
|