mirror of
https://github.com/holub/mame
synced 2025-07-03 17:08:39 +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
|
||||
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('\\');
|
||||
if (pathsep != std::string::npos)
|
||||
if (pathsep != decltype(t_path)::npos)
|
||||
{
|
||||
// create the path up to the file
|
||||
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);
|
||||
|
||||
// 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);
|
||||
dst.resize(char_count - 1);
|
||||
WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size() + 1, &dst[0], char_count - 1, nullptr, nullptr);
|
||||
int char_count = WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size(), nullptr, 0, nullptr, nullptr);
|
||||
dst.resize(char_count);
|
||||
WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size(), &dst[0], char_count, nullptr, nullptr);
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user