wchar filenames support - minor improvements

This commit is contained in:
gabime
2016-04-10 00:02:19 +03:00
parent 23200b08bb
commit 19dae96985
7 changed files with 62 additions and 62 deletions

View File

@@ -43,11 +43,11 @@ public:
}
void open(const filename_str_t& fname, bool truncate = false)
void open(const filename_t& fname, bool truncate = false)
{
close();
const filename_char_t* mode = truncate ? SPDLOG_FILENAME_T("wb") : SPDLOG_FILENAME_T("ab");
auto *mode = truncate ? SPDLOG_FILENAME_T("wb") : SPDLOG_FILENAME_T("ab");
_filename = fname;
for (int tries = 0; tries < open_tries; ++tries)
{
@@ -57,7 +57,7 @@ public:
std::this_thread::sleep_for(std::chrono::milliseconds(open_interval));
}
throw spdlog_ex("Failed opening file " + filename_to_bytes(_filename) + " for writing");
throw spdlog_ex("Failed opening file " + filename_to_str(_filename) + " for writing");
}
void reopen(bool truncate)
@@ -88,7 +88,7 @@ public:
size_t msg_size = msg.formatted.size();
auto data = msg.formatted.data();
if (std::fwrite(data, 1, msg_size, _fd) != msg_size)
throw spdlog_ex("Failed writing to file " + filename_to_bytes(_filename));
throw spdlog_ex("Failed writing to file " + filename_to_str(_filename));
if (_force_flush)
std::fflush(_fd);
@@ -98,19 +98,19 @@ public:
long size()
{
if (!_fd)
throw spdlog_ex("Cannot use size() on closed file " + filename_to_bytes(_filename));
throw spdlog_ex("Cannot use size() on closed file " + filename_to_str(_filename));
auto pos = ftell(_fd);
if (fseek(_fd, 0, SEEK_END) != 0)
throw spdlog_ex("fseek failed on file " + filename_to_bytes(_filename));
throw spdlog_ex("fseek failed on file " + filename_to_str(_filename));
auto file_size = ftell(_fd);
if(fseek(_fd, pos, SEEK_SET) !=0)
throw spdlog_ex("fseek failed on file " + filename_to_bytes(_filename));
throw spdlog_ex("fseek failed on file " + filename_to_str(_filename));
if (file_size == -1)
throw spdlog_ex("ftell failed on file " + filename_to_bytes(_filename));
throw spdlog_ex("ftell failed on file " + filename_to_str(_filename));
return file_size;
@@ -118,12 +118,12 @@ public:
}
const filename_str_t& filename() const
const filename_t& filename() const
{
return _filename;
}
static bool file_exists(const filename_str_t& name)
static bool file_exists(const filename_t& name)
{
return os::file_exists(name);
@@ -133,7 +133,7 @@ public:
private:
FILE* _fd;
filename_str_t _filename;
filename_t _filename;
bool _force_flush;