summaryrefslogtreecommitdiffstats
path: root/source/OSSupport
diff options
context:
space:
mode:
Diffstat (limited to 'source/OSSupport')
-rw-r--r--source/OSSupport/File.cpp15
-rw-r--r--source/OSSupport/File.h3
-rw-r--r--source/OSSupport/IsThread.cpp14
-rw-r--r--source/OSSupport/IsThread.h3
4 files changed, 22 insertions, 13 deletions
diff --git a/source/OSSupport/File.cpp b/source/OSSupport/File.cpp
index cc0916711..a4c9a22f4 100644
--- a/source/OSSupport/File.cpp
+++ b/source/OSSupport/File.cpp
@@ -287,6 +287,21 @@ bool cFile::Rename(const AString & a_OrigFileName, const AString & a_NewFileName
+bool cFile::IsFolder(const AString & a_Path)
+{
+ #ifdef _WIN32
+ DWORD FileAttrib = GetFileAttributes(a_Path.c_str());
+ return ((FileAttrib != INVALID_FILE_ATTRIBUTES) && ((FileAttrib & FILE_ATTRIBUTE_DIRECTORY) != 0));
+ #else
+ struct stat st;
+ return ((stat(a_Path.c_str(), &st) == 0) && S_ISDIR(st.st_mode));
+ #endif
+}
+
+
+
+
+
int cFile::Printf(const char * a_Fmt, ...)
{
AString buf;
diff --git a/source/OSSupport/File.h b/source/OSSupport/File.h
index 8a057afa8..d4ea0d3a8 100644
--- a/source/OSSupport/File.h
+++ b/source/OSSupport/File.h
@@ -99,6 +99,9 @@ public:
/// Renames a file, returns true if successful. May fail if dest already exists (libc-dependant)!
static bool Rename(const AString & a_OrigFileName, const AString & a_NewFileName);
+ /// Returns true if the specified path is a folder
+ static bool IsFolder(const AString & a_Path);
+
int Printf(const char * a_Fmt, ...);
private:
diff --git a/source/OSSupport/IsThread.cpp b/source/OSSupport/IsThread.cpp
index d5fbfcf19..e1ef84c17 100644
--- a/source/OSSupport/IsThread.cpp
+++ b/source/OSSupport/IsThread.cpp
@@ -53,11 +53,7 @@ static void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)
cIsThread::cIsThread(const AString & iThreadName) :
m_ThreadName(iThreadName),
m_ShouldTerminate(false),
- #ifdef _WIN32
- m_Handle(NULL)
- #else // _WIN32
- m_HasStarted(false)
- #endif // else _WIN32
+ m_Handle(NULL)
{
}
@@ -77,9 +73,9 @@ cIsThread::~cIsThread()
bool cIsThread::Start(void)
{
+ ASSERT(m_Handle == NULL); // Has already started one thread?
+
#ifdef _WIN32
- ASSERT(m_Handle == NULL); // Has already started one thread?
-
// Create the thread suspended, so that the mHandle variable is valid in the thread procedure
DWORD ThreadID = 0;
m_Handle = CreateThread(NULL, 0, thrExecute, this, CREATE_SUSPENDED, &ThreadID);
@@ -99,14 +95,11 @@ bool cIsThread::Start(void)
#endif // _DEBUG and _MSC_VER
#else // _WIN32
- ASSERT(!m_HasStarted);
-
if (pthread_create(&m_Handle, NULL, thrExecute, this))
{
LOGERROR("ERROR: Could not create thread \"%s\", !", m_ThreadName.c_str());
return false;
}
- m_HasStarted = true;
#endif // else _WIN32
return true;
@@ -158,7 +151,6 @@ bool cIsThread::Wait(void)
LOGD("Thread %s finished", m_ThreadName.c_str());
#endif // LOGD
- m_HasStarted = false;
return (res == 0);
#endif // else _WIN32
}
diff --git a/source/OSSupport/IsThread.h b/source/OSSupport/IsThread.h
index 9b7f0b73e..2ea8bf6f9 100644
--- a/source/OSSupport/IsThread.h
+++ b/source/OSSupport/IsThread.h
@@ -48,7 +48,7 @@ public:
/// Returns the OS-dependent thread ID for the caller's thread
static unsigned long GetCurrentID(void);
-private:
+protected:
AString m_ThreadName;
#ifdef _WIN32
@@ -66,7 +66,6 @@ private:
#else // _WIN32
pthread_t m_Handle;
- bool m_HasStarted;
static void * thrExecute(void * a_Param)
{