浏览代码

Tested FileReference.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@61 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 9 年前
父节点
当前提交
fcce81b431
共有 2 个文件被更改,包括 19 次插入9 次删除
  1. 15
    8
      filesystem.cpp
  2. 4
    1
      filesystem.hpp

+ 15
- 8
filesystem.cpp 查看文件

@@ -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;
}

+ 4
- 1
filesystem.hpp 查看文件

@@ -60,7 +60,7 @@ namespace CodeDweller {
@returns the size of file when FileReference was created or
last refreshed, or 0 if the file doesn't exist.
*/
long Size() const;
size_t Size() const;

/** Get full path.

@@ -99,6 +99,9 @@ namespace CodeDweller {
//
static std::string getErrorText();

/// Reset all members but the name and path. */
void reset();

/** Name provided to constructor. */
std::string name;


正在加载...
取消
保存