summaryrefslogtreecommitdiff
path: root/indra/llcommon/llfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llfile.cpp')
-rw-r--r--indra/llcommon/llfile.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index 4e868eb5a1..6b8f8e68c5 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -32,6 +32,10 @@
* $/LicenseInfo$
*/
+#if LL_WINDOWS
+#include <windows.h>
+#endif
+
#include "linden_common.h"
#include "llfile.h"
#include "llstring.h"
@@ -128,6 +132,50 @@ int LLFile::stat(const char* filename, llstat* filestatus)
#endif
}
+bool LLFile::isdir(const char *filename)
+{
+ llstat st;
+
+ return stat(filename, &st) == 0 && S_ISDIR(st.st_mode);
+}
+
+bool LLFile::isfile(const char *filename)
+{
+ llstat st;
+
+ return stat(filename, &st) == 0 && S_ISREG(st.st_mode);
+}
+
+const char *LLFile::tmpdir()
+{
+ static std::string utf8path;
+
+ if (utf8path.empty())
+ {
+ char sep;
+#if LL_WINDOWS
+ sep = '\\';
+
+ DWORD len = GetTempPathW(0, L"");
+ llutf16string utf16path;
+ utf16path.resize(len + 1);
+ len = GetTempPathW(static_cast<DWORD>(utf16path.size()), &utf16path[0]);
+ utf8path = utf16str_to_utf8str(utf16path);
+#else
+ sep = '/';
+
+ char *env = getenv("TMPDIR");
+
+ utf8path = env ? env : "/tmp/";
+#endif
+ if (utf8path[utf8path.size() - 1] != sep)
+ {
+ utf8path += sep;
+ }
+ }
+ return utf8path.c_str();
+}
+
/***************** Modified file stream created to overcome the incorrect behaviour of posix fopen in windows *******************/