|
|
@@ -20,6 +20,13 @@ |
|
|
|
// Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <cerrno>
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
#include "filesystem.hpp"
|
|
|
@@ -28,7 +35,7 @@ namespace CodeDweller { |
|
|
|
|
|
|
|
FileReference::FileReference(std::string fileName) :
|
|
|
|
name(fileName),
|
|
|
|
timestamp(0),
|
|
|
|
modTimestamp(0),
|
|
|
|
size_bytes(0),
|
|
|
|
fileExists(false),
|
|
|
|
fileIsDirectory(false) {
|
|
|
@@ -44,7 +51,7 @@ namespace CodeDweller { |
|
|
|
|
|
|
|
char *realPath = realpath(name.c_str(), NULL);
|
|
|
|
|
|
|
|
if (NULL == path) {
|
|
|
|
if (NULL == realPath) {
|
|
|
|
|
|
|
|
// Nothing to do if the file doesn't exist.
|
|
|
|
if (ENOENT == errno) {
|
|
|
@@ -52,12 +59,12 @@ namespace CodeDweller { |
|
|
|
}
|
|
|
|
|
|
|
|
// Something went wrong.
|
|
|
|
throw std::runtime_error("Error checking file \"" + name "\": " +
|
|
|
|
throw std::runtime_error("Error checking file \"" + name + "\": " +
|
|
|
|
getErrorText());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
path = *realPath;
|
|
|
|
path.assign(realPath);
|
|
|
|
free(realPath);
|
|
|
|
|
|
|
|
}
|
|
|
@@ -77,7 +84,7 @@ namespace CodeDweller { |
|
|
|
|
|
|
|
// Something went wrong.
|
|
|
|
throw std::runtime_error("Error updating status of file \"" +
|
|
|
|
path "\": " + getErrorText());
|
|
|
|
path + "\": " + getErrorText());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
@@ -99,7 +106,7 @@ namespace CodeDweller { |
|
|
|
return modTimestamp;
|
|
|
|
}
|
|
|
|
|
|
|
|
long FileReference::Size() const {
|
|
|
|
size_t FileReference::Size() const {
|
|
|
|
return size_bytes;
|
|
|
|
}
|
|
|
|
|
|
|
@@ -107,11 +114,11 @@ namespace CodeDweller { |
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
time_t FileReference::exists() const {
|
|
|
|
bool FileReference::exists() const {
|
|
|
|
return fileExists;
|
|
|
|
}
|
|
|
|
|
|
|
|
time_t FileReference::isDirectory() const {
|
|
|
|
bool FileReference::isDirectory() const {
|
|
|
|
return fileIsDirectory;
|
|
|
|
}
|
|
|
|
|