Posix fixes

This commit is contained in:
Lynix 2020-02-23 02:26:36 +01:00
parent 3fc67b3598
commit f084c30d70
3 changed files with 11 additions and 9 deletions

View File

@ -51,7 +51,7 @@ namespace Nz
path += ".so"; path += ".so";
dlerror(); // Clear error flag dlerror(); // Clear error flag
m_handle = dlopen(path.GetConstBuffer(), RTLD_LAZY | RTLD_GLOBAL); m_handle = dlopen(path.generic_u8string().data(), RTLD_LAZY | RTLD_GLOBAL);
if (m_handle) if (m_handle)
return true; return true;

View File

@ -19,7 +19,7 @@ namespace Nz
{ {
public: public:
DynLibImpl(DynLib* m_parent); DynLibImpl(DynLib* m_parent);
~DynLibImpl() = default; ~DynLibImpl();
DynLibFunc GetSymbol(const char* symbol, std::string* errorMessage) const; DynLibFunc GetSymbol(const char* symbol, std::string* errorMessage) const;
bool Load(const std::filesystem::path& libraryPath, std::string* errorMessage); bool Load(const std::filesystem::path& libraryPath, std::string* errorMessage);

View File

@ -76,8 +76,8 @@ namespace Nz
if (mode & OpenMode_Truncate) if (mode & OpenMode_Truncate)
flags |= O_TRUNC; flags |= O_TRUNC;
m_fileDescriptor = open64(filePath.generic_u8string().data(), flags, permissions); int fileDescriptor = open64(filePath.generic_u8string().data(), flags, permissions);
if (m_fileDescriptor == -1) if (fileDescriptor == -1)
{ {
NazaraError("Failed to open \"" + filePath.generic_u8string() + "\" : " + Error::GetLastSystemError()); NazaraError("Failed to open \"" + filePath.generic_u8string() + "\" : " + Error::GetLastSystemError());
return false; return false;
@ -96,16 +96,16 @@ namespace Nz
initialize_flock(lock); initialize_flock(lock);
if (fcntl(m_fileDescriptor, F_GETLK, &lock) == -1) if (fcntl(fileDescriptor, F_GETLK, &lock) == -1)
{ {
Close(); close(fileDescriptor);
NazaraError("Unable to detect presence of lock on the file"); NazaraError("Unable to detect presence of lock on the file");
return false; return false;
} }
if (lock.l_type != F_UNLCK) if (lock.l_type != F_UNLCK)
{ {
Close(); close(fileDescriptor);
NazaraError("A lock is present on the file"); NazaraError("A lock is present on the file");
return false; return false;
} }
@ -114,14 +114,16 @@ namespace Nz
{ {
initialize_flock(lock); initialize_flock(lock);
if (fcntl(m_fileDescriptor, F_SETLK, &lock) == -1) if (fcntl(fileDescriptor, F_SETLK, &lock) == -1)
{ {
Close(); close(fileDescriptor);
NazaraError("Unable to place a lock on the file"); NazaraError("Unable to place a lock on the file");
return false; return false;
} }
} }
m_fileDescriptor = fileDescriptor;
return true; return true;
} }