mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-26 10:31:34 +08:00
// support forward slash in windows
This commit is contained in:
parent
a8f72424db
commit
e9d42e059f
@ -489,13 +489,12 @@ SPDLOG_INLINE bool create_dir(filename_t path)
|
|||||||
std::basic_istringstream<char_type> istream(path);
|
std::basic_istringstream<char_type> istream(path);
|
||||||
filename_t token;
|
filename_t token;
|
||||||
filename_t cur_dir;
|
filename_t cur_dir;
|
||||||
char_type sep = '/';
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// support forward slash in windows
|
// support forward slash in windows
|
||||||
std::replace(path.begin(), path.end(), char_type('\\'), sep);
|
std::replace(path.begin(), path.end(), '/', folder_sep);
|
||||||
#endif
|
#endif
|
||||||
while (std::getline(istream, token, sep))
|
while (std::getline(istream, token, folder_sep))
|
||||||
{
|
{
|
||||||
if (!token.empty())
|
if (!token.empty())
|
||||||
{
|
{
|
||||||
@ -505,7 +504,7 @@ SPDLOG_INLINE bool create_dir(filename_t path)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur_dir += sep;
|
cur_dir += folder_sep;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -518,14 +517,11 @@ SPDLOG_INLINE bool create_dir(filename_t path)
|
|||||||
// "abc///" => "abc//"
|
// "abc///" => "abc//"
|
||||||
SPDLOG_INLINE filename_t dir_name(filename_t path)
|
SPDLOG_INLINE filename_t dir_name(filename_t path)
|
||||||
{
|
{
|
||||||
using char_type = filename_t::value_type;
|
|
||||||
char_type sep = '/';
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// support forward slash in windows
|
// support forward slash in windows
|
||||||
std::replace(path.begin(), path.end(), char_type('\\'), sep);
|
std::replace(path.begin(), path.end(), '/', folder_sep);
|
||||||
#endif
|
#endif
|
||||||
auto pos = path.find_last_of(sep);
|
auto pos = path.find_last_of(folder_sep);
|
||||||
return pos != filename_t::npos ? path.substr(0, pos) : filename_t{};
|
return pos != filename_t::npos ? path.substr(0, pos) : filename_t{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ SPDLOG_CONSTEXPR static const char *default_eol = SPDLOG_EOL;
|
|||||||
|
|
||||||
// folder separator
|
// folder separator
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const char folder_sep = '\\';
|
static const char folder_sep = '\\';
|
||||||
#else
|
#else
|
||||||
SPDLOG_CONSTEXPR static const char folder_sep = '/';
|
SPDLOG_CONSTEXPR static const char folder_sep = '/';
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user