mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
Using decltype() and removing +1/-1 "dance"
This commit is contained in:
parent
4a9e9742fd
commit
23175a3091
@ -207,11 +207,8 @@ osd_file::error osd_file::open(std::string const &orig_path, UINT32 openflags, p
|
|||||||
// create the path if necessary
|
// create the path if necessary
|
||||||
if ((ERROR_PATH_NOT_FOUND == err) && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS))
|
if ((ERROR_PATH_NOT_FOUND == err) && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS))
|
||||||
{
|
{
|
||||||
// the code below assumes these are the same
|
|
||||||
assert(std::string::npos == std::wstring::npos);
|
|
||||||
|
|
||||||
auto pathsep = t_path.rfind('\\');
|
auto pathsep = t_path.rfind('\\');
|
||||||
if (pathsep != std::string::npos)
|
if (pathsep != decltype(t_path)::npos)
|
||||||
{
|
{
|
||||||
// create the path up to the file
|
// create the path up to the file
|
||||||
t_path[pathsep] = 0;
|
t_path[pathsep] = 0;
|
||||||
|
@ -25,9 +25,9 @@ std::string &astring_from_utf8(std::string &dst, const char *s)
|
|||||||
std::basic_string<WCHAR> wstring = wstring_from_utf8(s);
|
std::basic_string<WCHAR> wstring = wstring_from_utf8(s);
|
||||||
|
|
||||||
// convert UTF-16 to "ANSI code page" string
|
// convert UTF-16 to "ANSI code page" string
|
||||||
int char_count = WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size() + 1, nullptr, 0, nullptr, nullptr);
|
int char_count = WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size(), nullptr, 0, nullptr, nullptr);
|
||||||
dst.resize(char_count - 1);
|
dst.resize(char_count);
|
||||||
WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size() + 1, &dst[0], char_count - 1, nullptr, nullptr);
|
WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size(), &dst[0], char_count, nullptr, nullptr);
|
||||||
|
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user