Fix compilation of testutils under Windows without NativeFileStream
This commit is contained in:
parent
c66420b1dc
commit
17fc55a2c6
|
@ -45,8 +45,11 @@ bool fileSystemItemExists(const string &path)
|
||||||
struct stat res;
|
struct stat res;
|
||||||
return stat(path.data(), &res) == 0;
|
return stat(path.data(), &res) == 0;
|
||||||
#else
|
#else
|
||||||
const auto widePath(NativeFileStream::makeWidePath(path));
|
const auto widePath(convertMultiByteToWide(path));
|
||||||
const auto fileType(GetFileAttributesW(widePath.get()));
|
if (!widePath.first) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto fileType(GetFileAttributesW(widePath.first.get()));
|
||||||
return fileType != INVALID_FILE_ATTRIBUTES;
|
return fileType != INVALID_FILE_ATTRIBUTES;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -57,8 +60,11 @@ bool fileExists(const string &path)
|
||||||
struct stat res;
|
struct stat res;
|
||||||
return stat(path.data(), &res) == 0 && !S_ISDIR(res.st_mode);
|
return stat(path.data(), &res) == 0 && !S_ISDIR(res.st_mode);
|
||||||
#else
|
#else
|
||||||
const auto widePath(NativeFileStream::makeWidePath(path));
|
const auto widePath(convertMultiByteToWide(path));
|
||||||
const auto fileType(GetFileAttributesW(widePath.get()));
|
if (!widePath.first) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto fileType(GetFileAttributesW(widePath.first.get()));
|
||||||
return (fileType != INVALID_FILE_ATTRIBUTES) && !(fileType & FILE_ATTRIBUTE_DIRECTORY) && !(fileType & FILE_ATTRIBUTE_DEVICE);
|
return (fileType != INVALID_FILE_ATTRIBUTES) && !(fileType & FILE_ATTRIBUTE_DIRECTORY) && !(fileType & FILE_ATTRIBUTE_DEVICE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -69,8 +75,11 @@ bool dirExists(const string &path)
|
||||||
struct stat res;
|
struct stat res;
|
||||||
return stat(path.data(), &res) == 0 && S_ISDIR(res.st_mode);
|
return stat(path.data(), &res) == 0 && S_ISDIR(res.st_mode);
|
||||||
#else
|
#else
|
||||||
const auto widePath(NativeFileStream::makeWidePath(path));
|
const auto widePath(convertMultiByteToWide(path));
|
||||||
const auto fileType(GetFileAttributesW(widePath.get()));
|
if (!widePath.first) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const auto fileType(GetFileAttributesW(widePath.first.get()));
|
||||||
return (fileType != INVALID_FILE_ATTRIBUTES) && (fileType & FILE_ATTRIBUTE_DIRECTORY);
|
return (fileType != INVALID_FILE_ATTRIBUTES) && (fileType & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -80,8 +89,11 @@ bool makeDir(const string &path)
|
||||||
#ifdef PLATFORM_UNIX
|
#ifdef PLATFORM_UNIX
|
||||||
return mkdir(path.data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0;
|
return mkdir(path.data(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == 0;
|
||||||
#else
|
#else
|
||||||
const auto widePath(NativeFileStream::makeWidePath(path));
|
const auto widePath(convertMultiByteToWide(path));
|
||||||
return CreateDirectoryW(widePath.get(), nullptr) || GetLastError() == ERROR_ALREADY_EXISTS;
|
if (!widePath.first) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return CreateDirectoryW(widePath.first.get(), nullptr) || GetLastError() == ERROR_ALREADY_EXISTS;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue