Utility class for getting file existence and last modified time
| 2976 | |
| 2977 | // Utility class for getting file existence and last modified time |
| 2978 | FileInfo::FileInfo(const std::string& path) |
| 2979 | : path_(path), exists_(false), lastModified_(0) |
| 2980 | { |
| 2981 | #ifdef _WIN32 |
| 2982 | struct _stat buffer; |
| 2983 | int result = _stat(path.c_str(), &buffer); |
| 2984 | #else |
| 2985 | struct stat buffer; |
| 2986 | int result = stat(path.c_str(), &buffer); |
| 2987 | #endif |
| 2988 | if (result != 0) { |
| 2989 | if (errno == ENOENT) |
| 2990 | exists_ = false; |
| 2991 | else |
| 2992 | throw Rcpp::file_io_error(errno, path); // #nocov |
| 2993 | } else { |
| 2994 | exists_ = true; |
| 2995 | lastModified_ = static_cast<double>(buffer.st_mtime); |
| 2996 | } |
| 2997 | } |
| 2998 | |
| 2999 | // Remove a file (call back into R for this) |
| 3000 | bool removeFile(const std::string& path) { |
nothing calls this directly
no test coverage detected