Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/diskfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bool DiskFile::CreateParentDirectory(std::string _pathname)
if (!DiskFile::CreateParentDirectory(path))
return false;

if (!CreateDirectory(wpath.c_str(), NULL))
if (!CreateDirectoryW(wpath.c_str(), NULL))
{
DWORD error = ::GetLastError();

Expand All @@ -116,7 +116,7 @@ bool DiskFile::Create(std::string _filename, u64 _filesize)

// Create the file
std::wstring wfilename = utf8::Utf8ToWide(_filename);
hFile = ::CreateFile(wfilename.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
hFile = ::CreateFileW(wfilename.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
DWORD error = ::GetLastError();
Expand All @@ -143,7 +143,7 @@ bool DiskFile::Create(std::string _filename, u64 _filesize)

::CloseHandle(hFile);
hFile = INVALID_HANDLE_VALUE;
::DeleteFile(wfilename.c_str());
::DeleteFileW(wfilename.c_str());

return false;
}
Expand All @@ -158,7 +158,7 @@ bool DiskFile::Create(std::string _filename, u64 _filesize)

::CloseHandle(hFile);
hFile = INVALID_HANDLE_VALUE;
::DeleteFile(wfilename.c_str());
::DeleteFileW(wfilename.c_str());

return false;
}
Expand Down Expand Up @@ -245,7 +245,7 @@ bool DiskFile::Open(const std::string &_filename, u64 _filesize)
filesize = _filesize;

std::wstring wfilename = utf8::Utf8ToWide(_filename);
hFile = ::CreateFile(wfilename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
hFile = ::CreateFileW(wfilename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
DWORD error = ::GetLastError();
Expand Down Expand Up @@ -377,8 +377,8 @@ std::unique_ptr< std::list<std::string> > DiskFile::FindFiles(std::string path,
std::list<std::string> *matches = new std::list<std::string>;

std::wstring wwildcard = utf8::Utf8ToWide(path + wildcard);
WIN32_FIND_DATA fd;
HANDLE h = ::FindFirstFile(wwildcard.c_str(), &fd);
WIN32_FIND_DATAW fd;
HANDLE h = ::FindFirstFileW(wwildcard.c_str(), &fd);
if (h != INVALID_HANDLE_VALUE)
{
do
Expand All @@ -401,7 +401,7 @@ std::unique_ptr< std::list<std::string> > DiskFile::FindFiles(std::string path,
// append without requiring ordering
matches->splice(matches->end(), *dirmatches);
}
} while (::FindNextFile(h, &fd));
} while (::FindNextFileW(h, &fd));
::FindClose(h);
}

Expand Down Expand Up @@ -954,7 +954,7 @@ bool DiskFile::Delete(void)
assert(hFile == INVALID_HANDLE_VALUE);

std::wstring wfilename = utf8::Utf8ToWide(filename);
if (filename.size() > 0 && 0 == _wunlink(wfilename.c_str()))
if (filename.size() > 0 && ::DeleteFileW(wfilename.c_str()))
{
exists = false;
return true;
Expand Down Expand Up @@ -1074,15 +1074,15 @@ std::string DiskFile::ErrorMessage(DWORD error)
std::string result;

LPVOID lpMsgBuf;
if (::FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
if (::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&lpMsgBuf,
(LPWSTR)&lpMsgBuf,
0,
NULL))
{
result = (char*)lpMsgBuf;
result = utf8::WideToUtf8((wchar_t*)lpMsgBuf);
LocalFree(lpMsgBuf);
}
else
Expand All @@ -1102,7 +1102,7 @@ bool DiskFile::Rename(std::string _filename)
std::wstring wfilename = utf8::Utf8ToWide(filename);
std::wstring _wfilename = utf8::Utf8ToWide(_filename);

if (::_wrename(wfilename.c_str(), _wfilename.c_str()) == 0)
if (::MoveFileW(wfilename.c_str(), _wfilename.c_str()))
{
filename.swap(_filename);

Expand Down
2 changes: 2 additions & 0 deletions src/par2cmdline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ int main(int argc, char* argv[])
#ifdef _MSC_VER
// Memory leak checking
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF | /*_CRTDBG_CHECK_CRT_DF | */_CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

#ifdef _WIN32
SetConsoleOutputCP(CP_UTF8);

utf8::WideToUtf8ArgsAdapter wargsAdapter{ argc, wargv };
Expand Down