mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-14 12:05:52 +00:00
Return null when file fails to oepn
This commit is contained in:
parent
74aebf106f
commit
39a8581825
@ -279,11 +279,11 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo
|
|||||||
#if HECL_UCS2
|
#if HECL_UCS2
|
||||||
FILE* fp = _wfopen(path, mode);
|
FILE* fp = _wfopen(path, mode);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
LogModule.report(LogVisor::FatalError, L"fopen %s: %s", path, _wcserror(errno));
|
return nullptr;
|
||||||
#else
|
#else
|
||||||
FILE* fp = fopen(path, mode);
|
FILE* fp = fopen(path, mode);
|
||||||
if (!fp)
|
if (!fp)
|
||||||
LogModule.report(LogVisor::FatalError, "fopen %s: %s", path, strerror(errno));
|
return nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (lock != FileLockType::None)
|
if (lock != FileLockType::None)
|
||||||
@ -293,7 +293,7 @@ static inline FILE* Fopen(const SystemChar* path, const SystemChar* mode, FileLo
|
|||||||
LockFileEx((HANDLE)(uintptr_t)_fileno(fp), (lock == FileLockType::Write) ? LOCKFILE_EXCLUSIVE_LOCK : 0, 0, 0, 1, &ov);
|
LockFileEx((HANDLE)(uintptr_t)_fileno(fp), (lock == FileLockType::Write) ? LOCKFILE_EXCLUSIVE_LOCK : 0, 0, 0, 1, &ov);
|
||||||
#else
|
#else
|
||||||
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
|
if (flock(fileno(fp), ((lock == FileLockType::Write) ? LOCK_EX : LOCK_SH) | LOCK_NB))
|
||||||
LogModule.report(LogVisor::FatalError, "flock %s: %s", path, strerror(errno));
|
LogModule.report(LogVisor::Error, "flock %s: %s", path, strerror(errno));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user