Moving code around and renaming files.

This commit is contained in:
Branimir Karadžić
2017-07-15 20:58:27 -07:00
parent 939d5e2681
commit d4906fd3bd
25 changed files with 557 additions and 490 deletions

View File

@@ -3,14 +3,13 @@
* License: https://github.com/bkaradzic/bx#license-bsd-2-clause
*/
#include <bx/string.h>
#include <bx/os.h>
#include <bx/uint32_t.h>
#include <bx/string.h>
#if !BX_PLATFORM_NONE
#include <stdio.h>
#include <sys/stat.h>
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
# include <windows.h>
@@ -298,97 +297,6 @@ namespace bx
#endif // BX_COMPILER_
}
bool getTempPath(char* _out, uint32_t* _inOutSize)
{
#if BX_PLATFORM_WINDOWS
uint32_t len = ::GetTempPathA(*_inOutSize, _out);
bool result = len != 0 && len < *_inOutSize;
*_inOutSize = len;
return result;
#else
static const char* s_tmp[] =
{
"TMPDIR",
"TMP",
"TEMP",
"TEMPDIR",
NULL
};
for (const char** tmp = s_tmp; *tmp != NULL; ++tmp)
{
uint32_t len = *_inOutSize;
*_out = '\0';
bool result = getenv(*tmp, _out, &len);
if (result
&& len != 0
&& len < *_inOutSize)
{
*_inOutSize = len;
return result;
}
}
FileInfo fi;
if (stat("/tmp", fi)
&& FileInfo::Directory == fi.m_type)
{
strCopy(_out, *_inOutSize, "/tmp");
*_inOutSize = 4;
return true;
}
return false;
#endif // BX_PLATFORM_*
}
bool stat(const char* _filePath, FileInfo& _fileInfo)
{
_fileInfo.m_size = 0;
_fileInfo.m_type = FileInfo::Count;
#if BX_COMPILER_MSVC
struct ::_stat64 st;
int32_t result = ::_stat64(_filePath, &st);
if (0 != result)
{
return false;
}
if (0 != (st.st_mode & _S_IFREG) )
{
_fileInfo.m_type = FileInfo::Regular;
}
else if (0 != (st.st_mode & _S_IFDIR) )
{
_fileInfo.m_type = FileInfo::Directory;
}
#else
struct ::stat st;
int32_t result = ::stat(_filePath, &st);
if (0 != result)
{
return false;
}
if (0 != (st.st_mode & S_IFREG) )
{
_fileInfo.m_type = FileInfo::Regular;
}
else if (0 != (st.st_mode & S_IFDIR) )
{
_fileInfo.m_type = FileInfo::Directory;
}
#endif // BX_COMPILER_MSVC
_fileInfo.m_size = st.st_size;
return true;
}
void* exec(const char* const* _argv)
{
#if BX_PLATFORM_LINUX || BX_PLATFORM_HURD