nuke non-portable Windows file operations

This commit is contained in:
Tropical 2026-04-10 17:04:46 -05:00
parent 05adecade7
commit ff7baaac3b
4 changed files with 0 additions and 22 deletions

View file

@ -49,13 +49,9 @@ bool FileSeek(std::FILE* file, int64_t offset, int origin) {
// SecurityException - if a security manager exists and its checkRead method
// denies read access to the file.
FileInputStream::FileInputStream(const File& file) : m_fileHandle(nullptr) {
#if defined(_WIN32)
m_fileHandle = _wfopen(file.getPath().c_str(), "rb");
#else
const std::string nativePath =
std::filesystem::path(file.getPath()).string();
m_fileHandle = std::fopen(nativePath.c_str(), "rb");
#endif
if (m_fileHandle == nullptr) {
assert(0);

View file

@ -26,13 +26,9 @@ FileOutputStream::FileOutputStream(const File& file) : m_fileHandle(nullptr) {
return;
}
#if defined(_WIN32)
m_fileHandle = _wfopen(file.getPath().c_str(), "wb");
#else
const std::string nativePath =
std::filesystem::path(file.getPath()).string();
m_fileHandle = std::fopen(nativePath.c_str(), "wb");
#endif
if (m_fileHandle == nullptr) {
// TODO 4J Stu - Any form of error/exception handling

View file

@ -6,19 +6,12 @@
namespace {
std::FILE* OpenBinaryFileForReadWrite(const File& file) {
#if defined(_WIN32)
std::FILE* stream = _wfopen(file.getPath().c_str(), "r+b");
if (stream == nullptr) {
stream = _wfopen(file.getPath().c_str(), "w+b");
}
#else
const std::string nativePath =
std::filesystem::path(file.getPath()).string();
std::FILE* stream = std::fopen(nativePath.c_str(), "r+b");
if (stream == nullptr) {
stream = std::fopen(nativePath.c_str(), "w+b");
}
#endif
return stream;
}

View file

@ -7,19 +7,12 @@
namespace {
std::FILE* OpenBinaryFileForReadWrite(const File& file) {
#if defined(_WIN32)
std::FILE* stream = _wfopen(file.getPath().c_str(), "r+b");
if (stream == nullptr) {
stream = _wfopen(file.getPath().c_str(), "w+b");
}
#else
const std::string nativePath =
std::filesystem::path(file.getPath()).string();
std::FILE* stream = std::fopen(nativePath.c_str(), "r+b");
if (stream == nullptr) {
stream = std::fopen(nativePath.c_str(), "w+b");
}
#endif
return stream;
}
} // namespace