Ver código fonte

Tested FileReference.


git-svn-id: https://svn.microneil.com/svn/CodeDweller/branches/adeniz_1@61 d34b734f-a00e-4b39-a726-e4eeb87269ab
adeniz_1
adeniz 9 anos atrás
pai
commit
fcce81b431
2 arquivos alterados com 19 adições e 9 exclusões
  1. 15
    8
      filesystem.cpp
  2. 4
    1
      filesystem.hpp

+ 15
- 8
filesystem.cpp Ver arquivo

@@ -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 Ver arquivo

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


Carregando…
Cancelar
Salvar