aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcommon/llfile.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-06 18:24:57 -0500
committerJacek Antonelli2008-09-06 18:25:07 -0500
commit798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch)
tree1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llcommon/llfile.h
parentSecond Life viewer sources 1.20.15 (diff)
downloadmeta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2
meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz
Second Life viewer sources 1.21.0-RC
Diffstat (limited to 'linden/indra/llcommon/llfile.h')
-rw-r--r--linden/indra/llcommon/llfile.h81
1 files changed, 66 insertions, 15 deletions
diff --git a/linden/indra/llcommon/llfile.h b/linden/indra/llcommon/llfile.h
index 189edbf..f3e3af5 100644
--- a/linden/indra/llcommon/llfile.h
+++ b/linden/indra/llcommon/llfile.h
@@ -50,31 +50,45 @@ typedef FILE LLFILE;
50#define USE_LLFILESTREAMS 0 50#define USE_LLFILESTREAMS 0
51#endif 51#endif
52 52
53#include <sys/stat.h>
53 54
54#if LL_WINDOWS 55#if LL_WINDOWS
55// windows version of stat function and stat data structure are called _stat 56// windows version of stat function and stat data structure are called _stat
56typedef struct _stat llstat; 57typedef struct _stat llstat;
57#else 58#else
58#include <sys/stat.h>
59typedef struct stat llstat; 59typedef struct stat llstat;
60#endif 60#endif
61 61
62#ifndef S_ISREG
63# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
64#endif
65
66#ifndef S_ISDIR
67# define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
68#endif
69
70#include "llstring.h" // safe char* -> std::string conversion
71
62class LLFile 72class LLFile
63{ 73{
64public: 74public:
65 // All these functions take UTF8 path/filenames. 75 // All these functions take UTF8 path/filenames.
66 static LLFILE* fopen(const char* filename,const char* accessmode); /* Flawfinder: ignore */ 76 static LLFILE* fopen(const std::string& filename,const char* accessmode); /* Flawfinder: ignore */
67 static LLFILE* _fsopen(const char* filename,const char* accessmode,int sharingFlag); 77 static LLFILE* _fsopen(const std::string& filename,const char* accessmode,int sharingFlag);
68 78
69 // perms is a permissions mask like 0777 or 0700. In most cases it will 79 // perms is a permissions mask like 0777 or 0700. In most cases it will
70 // be overridden by the user's umask. It is ignored on Windows. 80 // be overridden by the user's umask. It is ignored on Windows.
71 static int mkdir(const char* filename, int perms = 0700); 81 static int mkdir(const std::string& filename, int perms = 0700);
72 82
73 static int rmdir(const char* filename); 83 static int rmdir(const std::string& filename);
74 static int remove(const char* filename); 84 static int remove(const std::string& filename);
75 static int rename(const char* filename,const char* newname); 85 static int rename(const std::string& filename,const std::string& newname);
76 static int stat(const char* filename,llstat* file_status); 86 static int stat(const std::string& filename,llstat* file_status);
77 static LLFILE * _Fiopen(const char *filename, std::ios::openmode mode,int); // protection currently unused 87 static bool isdir(const std::string& filename);
88 static bool isfile(const std::string& filename);
89 static LLFILE * _Fiopen(const std::string& filename, std::ios::openmode mode,int); // protection currently unused
90
91 static const char * tmpdir();
78}; 92};
79 93
80 94
@@ -93,7 +107,7 @@ public:
93 { // construct unopened 107 { // construct unopened
94 } 108 }
95 109
96 explicit llifstream(const char *_Filename, 110 explicit llifstream(const std::string& _Filename,
97 ios_base::openmode _Mode = ios_base::in, 111 ios_base::openmode _Mode = ios_base::in,
98 int _Prot = (int)ios_base::_Openprot); 112 int _Prot = (int)ios_base::_Openprot);
99 113
@@ -110,7 +124,7 @@ public:
110 return _Filebuffer; 124 return _Filebuffer;
111 } 125 }
112 bool is_open() const; 126 bool is_open() const;
113 void open(const char* _Filename, /* Flawfinder: ignore */ 127 void open(const std::string& _Filename, /* Flawfinder: ignore */
114 ios_base::openmode _Mode = ios_base::in, 128 ios_base::openmode _Mode = ios_base::in,
115 int _Prot = (int)ios_base::_Openprot); 129 int _Prot = (int)ios_base::_Openprot);
116 void close(); 130 void close();
@@ -133,7 +147,7 @@ public:
133 { // construct unopened 147 { // construct unopened
134 } 148 }
135 149
136 explicit llofstream(const char *_Filename, 150 explicit llofstream(const std::string& _Filename,
137 std::ios_base::openmode _Mode = ios_base::out, 151 std::ios_base::openmode _Mode = ios_base::out,
138 int _Prot = (int)std::ios_base::_Openprot); 152 int _Prot = (int)std::ios_base::_Openprot);
139 153
@@ -154,7 +168,7 @@ public:
154 168
155 bool is_open() const; 169 bool is_open() const;
156 170
157 void open(const char *_Filename,ios_base::openmode _Mode = ios_base::out,int _Prot = (int)ios_base::_Openprot); /* Flawfinder: ignore */ 171 void open(const std::string& _Filename,ios_base::openmode _Mode = ios_base::out,int _Prot = (int)ios_base::_Openprot); /* Flawfinder: ignore */
158 172
159 void close(); 173 void close();
160 174
@@ -167,8 +181,45 @@ private:
167 181
168#else 182#else
169//Use standard file streams on non windows platforms 183//Use standard file streams on non windows platforms
170#define llifstream std::ifstream 184//#define llifstream std::ifstream
171#define llofstream std::ofstream 185//#define llofstream std::ofstream
186
187class llifstream : public std::ifstream
188{
189public:
190 llifstream() : std::ifstream()
191 {
192 }
193
194 explicit llifstream(const std::string& _Filename, std::_Ios_Openmode _Mode = in)
195 : std::ifstream(_Filename.c_str(), _Mode)
196 {
197 }
198 void open(const std::string& _Filename, std::_Ios_Openmode _Mode = in) /* Flawfinder: ignore */
199 {
200 std::ifstream::open(_Filename.c_str(), _Mode);
201 }
202};
203
204
205class llofstream : public std::ofstream
206{
207public:
208 llofstream() : std::ofstream()
209 {
210 }
211
212 explicit llofstream(const std::string& _Filename, std::_Ios_Openmode _Mode = out)
213 : std::ofstream(_Filename.c_str(), _Mode)
214 {
215 }
216
217 void open(const std::string& _Filename, std::_Ios_Openmode _Mode = out) /* Flawfinder: ignore */
218 {
219 std::ofstream::open(_Filename.c_str(), _Mode);
220 }
221
222};
172 223
173#endif 224#endif
174 225