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";
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)
return true;

View File

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

View File

@ -76,8 +76,8 @@ namespace Nz
if (mode & OpenMode_Truncate)
flags |= O_TRUNC;
m_fileDescriptor = open64(filePath.generic_u8string().data(), flags, permissions);
if (m_fileDescriptor == -1)
int fileDescriptor = open64(filePath.generic_u8string().data(), flags, permissions);
if (fileDescriptor == -1)
{
NazaraError("Failed to open \"" + filePath.generic_u8string() + "\" : " + Error::GetLastSystemError());
return false;
@ -96,16 +96,16 @@ namespace Nz
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");
return false;
}
if (lock.l_type != F_UNLCK)
{
Close();
close(fileDescriptor);
NazaraError("A lock is present on the file");
return false;
}
@ -114,14 +114,16 @@ namespace Nz
{
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");
return false;
}
}
m_fileDescriptor = fileDescriptor;
return true;
}