diff options
| author | 2017-05-24 12:10:49 +0200 | |
|---|---|---|
| committer | 2017-05-24 12:10:49 +0200 | |
| commit | 8b81b079117e37d8e09d110bdffd3e6eaf2a3543 (patch) | |
| tree | df3940628d12129edd67f9ce8f4282129fbb8956 /src/modules/file | |
| parent | Build also in debug mode for windows (#2192) (diff) | |
| download | KVIrc-8b81b079117e37d8e09d110bdffd3e6eaf2a3543.tar.gz KVIrc-8b81b079117e37d8e09d110bdffd3e6eaf2a3543.tar.bz2 KVIrc-8b81b079117e37d8e09d110bdffd3e6eaf2a3543.zip | |
Make Windows code Unicode-aware (#2219)
Diffstat (limited to 'src/modules/file')
| -rw-r--r-- | src/modules/file/libkvifile.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/modules/file/libkvifile.cpp b/src/modules/file/libkvifile.cpp index b37e02dd4..84d7d5d37 100644 --- a/src/modules/file/libkvifile.cpp +++ b/src/modules/file/libkvifile.cpp @@ -1478,19 +1478,25 @@ static bool file_kvs_fnc_diskSpace(KviKvsModuleFunctionCall * c) if(szPath.isEmpty()) szPath = "."; - const char * pcPath = szPath.toUtf8().data(); long long int fTotal; long long int fFree; // this for win #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) ULARGE_INTEGER free, total; - GetDiskFreeSpaceExA((LPCTSTR)pcPath, NULL, &total, &free); + if (GetDiskFreeSpaceEx(szPath.toStdWString().c_str(), NULL, &total, &free) == 0) { + c->warning(__tr2qs("An error occurred retrieving the amount of free space in '%Q'"), &szPath); + return true; + } fFree = free.QuadPart; fTotal = total.QuadPart; #else // this one for linux and macos + auto pcPath = szPath.toUtf8(); struct statvfs stFileSystem; - statvfs(pcPath, &stFileSystem); + if (statvfs(pcPath.data(), &stFileSystem) == -1) { + c->warning(__tr2qs("An error occurred retrieving the amount of free space in '%Q'"), &szPath); + return true; + } fFree = stFileSystem.f_bavail * stFileSystem.f_bsize; fTotal = stFileSystem.f_blocks * stFileSystem.f_bsize; #endif |
