diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-04-21 20:50:07 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-04-25 21:27:49 +0100 |
commit | a42d43d09cf2e13a8e0a884efb70bd32133e4888 (patch) | |
tree | 24ad650756c98c389eb392367130f7ba526b965f | |
parent | Ingest package metadata basics (diff) | |
download | gentoobrowse-api-a42d43d09cf2e13a8e0a884efb70bd32133e4888.tar.bz2 gentoobrowse-api-a42d43d09cf2e13a8e0a884efb70bd32133e4888.tar.xz gentoobrowse-api-a42d43d09cf2e13a8e0a884efb70bd32133e4888.zip |
File handle stuff should accept path args, not strings
-rw-r--r-- | gentoobrowse-api/service/fileUtils.cpp | 12 | ||||
-rw-r--r-- | gentoobrowse-api/service/fileUtils.h | 6 |
2 files changed, 9 insertions, 9 deletions
diff --git a/gentoobrowse-api/service/fileUtils.cpp b/gentoobrowse-api/service/fileUtils.cpp index 05f797f..c9bcc34 100644 --- a/gentoobrowse-api/service/fileUtils.cpp +++ b/gentoobrowse-api/service/fileUtils.cpp @@ -14,11 +14,11 @@ namespace Gentoo { } } - FileHandle::FileHandle(const std::string & path) : + FileHandle::FileHandle(const boost::filesystem::path & path) : fh(open(path.c_str(), O_RDONLY)) { if (fh < 0) { - throw std::runtime_error("Failed to open " + path); + throw std::runtime_error("Failed to open " + path.string()); } } @@ -27,20 +27,20 @@ namespace Gentoo { close(fh); } - FileHandleStat::FileHandleStat(const std::string & path) : + FileHandleStat::FileHandleStat(const boost::filesystem::path & path) : FileHandle(path) { if (fstat(fh, &st)) { - throw std::runtime_error("Failed to stat " + path); + throw std::runtime_error("Failed to stat " + path.string()); } } - MemMap::MemMap(const std::string & path) : + MemMap::MemMap(const boost::filesystem::path & path) : FileHandleStat(path), data(mmap(0, st.st_size, PROT_READ, MAP_SHARED, fh, 0)) { if (data == (void*)-1) { - throw std::runtime_error("Failed to mmap " + path); + throw std::runtime_error("Failed to mmap " + path.string()); } } diff --git a/gentoobrowse-api/service/fileUtils.h b/gentoobrowse-api/service/fileUtils.h index c9a2ec4..b447c4d 100644 --- a/gentoobrowse-api/service/fileUtils.h +++ b/gentoobrowse-api/service/fileUtils.h @@ -12,7 +12,7 @@ namespace Gentoo { class FileHandle { public: - FileHandle(const std::string & path); + FileHandle(const boost::filesystem::path & path); ~FileHandle(); protected: @@ -21,7 +21,7 @@ namespace Gentoo { class FileHandleStat : public FileHandle { public: - FileHandleStat(const std::string & path); + FileHandleStat(const boost::filesystem::path & path); protected: struct stat st; @@ -29,7 +29,7 @@ namespace Gentoo { class MemMap : public FileHandleStat { public: - MemMap(const std::string & path); + MemMap(const boost::filesystem::path & path); ~MemMap(); protected: |