aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/unicode_file.cpp
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-03-29 07:34:34 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:47 +0100
commitc3f80439a841120d7e17108da11cc343d5168b8c (patch)
tree80d958b3de2fcdbaddd1f867bee5f90a42329fea /src/utils/unicode_file.cpp
parent15c0132fd080003f2bf47749e30e1f724b249341 (diff)
downloadusdx-c3f80439a841120d7e17108da11cc343d5168b8c.tar.gz
usdx-c3f80439a841120d7e17108da11cc343d5168b8c.tar.xz
usdx-c3f80439a841120d7e17108da11cc343d5168b8c.zip
new file classes for text and binary files
Diffstat (limited to '')
-rw-r--r--src/utils/unicode_file.cpp (renamed from src/utils/file.cpp)20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/utils/file.cpp b/src/utils/unicode_file.cpp
index f97fc2e4..c47bfd36 100644
--- a/src/utils/file.cpp
+++ b/src/utils/unicode_file.cpp
@@ -24,7 +24,7 @@
* $Id$
*/
-#include "file.hpp"
+#include "unicode_file.hpp"
#include <string>
#include <locale>
@@ -32,28 +32,38 @@
namespace usdx
{
- File::File(const std::string& filename) : file(filename.c_str(), std::wifstream::in)
+ UnicodeFile::UnicodeFile(const std::string& filename) : file(filename.c_str(), std::wifstream::in)
{
std::locale global_loc = std::locale();
std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet());
file.imbue(loc);
}
- File::File(const boost::filesystem::wpath& path) : file(path, std::wifstream::in)
+ UnicodeFile::UnicodeFile(const boost::filesystem::wpath& path) : file(path, std::wifstream::in)
{
std::locale global_loc = std::locale();
std::locale loc(global_loc, new boost::program_options::detail::utf8_codecvt_facet());
file.imbue(loc);
}
- File::~File(void)
+ UnicodeFile::~UnicodeFile(void)
{
file.close();
}
- std::wistream &File::stream(void)
+ boost::filesystem::wifstream &UnicodeFile::stream(void)
{
return file;
}
+ const std::streamsize UnicodeFile::get_filesize(void)
+ {
+ std::streampos position = stream().tellg();
+
+ stream().seekg (0, std::ios::end);
+ std::streamsize length = stream().tellg();
+ stream().seekg (position);
+
+ return length;
+ }
};