MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / FileInfo

Class FileInfo

src/attributes.cpp:49–106  ·  view source on GitHub ↗

Utility class for getting file existence and last modified time

Source from the content-addressed store, hash-verified

47
48 // Utility class for getting file existence and last modified time
49 class FileInfo {
50 public:
51
52 // create from path
53 explicit FileInfo(const std::string& path);
54
55 // create from R list
56 explicit FileInfo(const List& fileInfo) { // #nocov start
57 path_ = as<std::string>(fileInfo["path"]);
58 exists_ = as<bool>(fileInfo["exists"]);
59 lastModified_ = as<double>(fileInfo["lastModified"]);
60 } // #nocov end
61
62 // convert to R list
63 List toList() const {
64 List fileInfo;
65 fileInfo["path"] = path_;
66 fileInfo["exists"] = exists_;
67 fileInfo["lastModified"] = lastModified_;
68 return fileInfo;
69 }
70
71 std::string path() const { return path_; }
72 bool exists() const { return exists_; }
73 double lastModified() const { return lastModified_; }
74
75 std::string extension() const {
76 std::string::size_type pos = path_.find_last_of('.');
77 if (pos != std::string::npos)
78 return path_.substr(pos);
79 else
80 return ""; // #nocov
81 }
82
83 bool operator<(const FileInfo& other) const {
84 return path_ < other.path_;
85 };
86
87 bool operator==(const FileInfo& other) const {
88 return path_ == other.path_ &&
89 exists_ == other.exists_ &&
90 lastModified_ == other.lastModified_;
91 };
92
93 bool operator!=(const FileInfo& other) const {
94 return ! (*this == other);
95 };
96
97 std::ostream& operator<<(std::ostream& os) const {
98 os << path_;
99 return os;
100 }
101
102 private:
103 std::string path_;
104 bool exists_;
105 double lastModified_;
106 };

Callers 9

addUniqueDependencyFunction · 0.85
parseSourceDependenciesFunction · 0.85
ExportsGeneratorMethod · 0.85
commitMethod · 0.85
removeFileFunction · 0.85
createDirectoryFunction · 0.85
SourceCppDynlibMethod · 0.85
isBuiltMethod · 0.85
isSourceDirtyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected