diff --git a/Sources/Plasma/Apps/plPythonPack/main.cpp b/Sources/Plasma/Apps/plPythonPack/main.cpp index 6cc8ae6b..eede46de 100644 --- a/Sources/Plasma/Apps/plPythonPack/main.cpp +++ b/Sources/Plasma/Apps/plPythonPack/main.cpp @@ -75,7 +75,7 @@ void WritePythonFile(const plFileName &fileName, const plFileName &path, hsStrea { hsUNIXStream pyStream, glueStream; plFileName filePath; - size_t filestart = fileName.AsString().FindLast('.'); + ssize_t filestart = fileName.AsString().FindLast('.'); if (filestart >= 0) filePath = fileName.AsString().Substr(filestart+1); else diff --git a/Sources/Plasma/CoreLib/hsThread_Unix.cpp b/Sources/Plasma/CoreLib/hsThread_Unix.cpp index 7ac17a66..1e298282 100644 --- a/Sources/Plasma/CoreLib/hsThread_Unix.cpp +++ b/Sources/Plasma/CoreLib/hsThread_Unix.cpp @@ -284,6 +284,7 @@ hsSemaphore::hsSemaphore(int initialValue, const char* name) } else { /* Anonymous semaphore shared between threads */ int shared = 0; // 1 if sharing between processes + fPSema = new sem_t; int status = sem_init(fPSema, shared, initialValue); hsThrowIfOSErr(status); } @@ -307,6 +308,7 @@ hsSemaphore::~hsSemaphore() } else { status = sem_destroy(fPSema); } + delete fPSema; hsThrowIfOSErr(status); #else int status = ::pthread_cond_destroy(&fPCond); @@ -321,7 +323,10 @@ bool hsSemaphore::TryWait() { #ifdef USE_SEMA int status = ::sem_trywait(fPSema); - return status != EAGAIN; + if (status != 0) { + return errno != EAGAIN; + } + return true; #else int status = ::pthread_mutex_trylock(&fPMutex); hsThrowIfOSErr(status); diff --git a/Sources/Plasma/CoreLib/plFileSystem.cpp b/Sources/Plasma/CoreLib/plFileSystem.cpp index 51aa3dc2..f1d3bd62 100644 --- a/Sources/Plasma/CoreLib/plFileSystem.cpp +++ b/Sources/Plasma/CoreLib/plFileSystem.cpp @@ -540,37 +540,6 @@ plFileName plFileSystem::GetCurrentAppPath() #endif } -plFileName plFileSystem::GetTempFilename(const char *prefix, const plFileName &path) -{ -#if HS_BUILD_FOR_WIN32 - // GetTempFileName() never uses more than 3 chars for the prefix - wchar_t wprefix[4]; - for (size_t i=0; i<4; ++i) - wprefix[i] = prefix[i]; - wprefix[3] = 0; - - wchar_t temp[MAX_PATH]; - if (GetTempFileNameW(path.AsString().ToWchar(), wprefix, 0, temp)) - return plString::FromWchar(temp); - - return ""; -#else - plFileName tmpdir = path; - if (!tmpdir.IsValid()) - tmpdir = "/tmp"; - - // "/tmp/prefixXXXXXX" - size_t temp_len = tmpdir.GetSize() + strlen(prefix) + 7; - char *temp = new char[temp_len + 1]; - snprintf(temp, temp_len + 1, "%s/%sXXXXXX", tmpdir.AsString().c_str(), prefix); - mktemp(temp); - plFileName result = temp; - delete [] temp; - - return result; -#endif -} - plString plFileSystem::ConvertFileSize(uint64_t size) { const char* labels[] = { "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" }; diff --git a/Sources/Plasma/CoreLib/plFileSystem.h b/Sources/Plasma/CoreLib/plFileSystem.h index 317e8a03..1d3a2ce9 100644 --- a/Sources/Plasma/CoreLib/plFileSystem.h +++ b/Sources/Plasma/CoreLib/plFileSystem.h @@ -333,12 +333,6 @@ namespace plFileSystem /** Get the full path and filename of the current process. */ plFileName GetCurrentAppPath(); - /** Create a temporary filename. If path is specified, the returned - * filename will be relative to the supplied path -- otherwise, the - * system temp path is used. - */ - plFileName GetTempFilename(const char *prefix = "tmp", const plFileName &path = ""); - /** Convert a file size from bytes to a human readable size. */ plString ConvertFileSize(uint64_t size); }