aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Filesystem
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Filesystem')
-rw-r--r--src/libjin/Filesystem/Buffer.h102
-rw-r--r--src/libjin/Filesystem/Filesystem.cpp96
-rw-r--r--src/libjin/Filesystem/Filesystem.h40
3 files changed, 119 insertions, 119 deletions
diff --git a/src/libjin/Filesystem/Buffer.h b/src/libjin/Filesystem/Buffer.h
index 5598f66..a47b0ef 100644
--- a/src/libjin/Filesystem/Buffer.h
+++ b/src/libjin/Filesystem/Buffer.h
@@ -6,62 +6,62 @@
namespace jin
{
-namespace filesystem
-{
+ namespace filesystem
+ {
- /**
- * ڶϷָռbuffer
- */
- class Buffer
- {
- public:
- Buffer() : data(0), size(0) {}
- Buffer(const Buffer& src)
- {
- delete[] data;
- size = src.size;
- data = new char[size];
- memcpy(data, src.data, size);
- }
- Buffer(void* d, int s)
- {
- data = new char[size];
- memcpy(data, d, size);
- size = s;
- }
- Buffer(size_t s)
- {
- data = new char[s];
- memset(data, 0, s);
- size = s;
- }
- ~Buffer()
- {
- delete[] data;
- size = 0;
- }
- void operator = (const Buffer& buffer)
- {
- delete[] data;
- size = buffer.size;
- data = new char[size];
- memcpy(data, buffer.data, size);
- }
+ /**
+ * ڶϷָռbuffer
+ */
+ class Buffer
+ {
+ public:
+ Buffer() : data(0), size(0) {}
+ Buffer(const Buffer& src)
+ {
+ delete[] data;
+ size = src.size;
+ data = new char[size];
+ memcpy(data, src.data, size);
+ }
+ Buffer(void* d, int s)
+ {
+ data = new char[size];
+ memcpy(data, d, size);
+ size = s;
+ }
+ Buffer(size_t s)
+ {
+ data = new char[s];
+ memset(data, 0, s);
+ size = s;
+ }
+ ~Buffer()
+ {
+ delete[] data;
+ size = 0;
+ }
+ void operator = (const Buffer& buffer)
+ {
+ delete[] data;
+ size = buffer.size;
+ data = new char[size];
+ memcpy(data, buffer.data, size);
+ }
- void clear()
- {
- if (data == nullptr)
- return;
- free(data);
- data = nullptr;
- }
+ void clear()
+ {
+ if (data == nullptr)
+ return;
+ free(data);
+ data = nullptr;
+ }
- void* data;
- unsigned int size;
+ void* data;
+ unsigned int size;
- };
+ };
-} // filesystem
+ } // filesystem
} // jin
#endif \ No newline at end of file
diff --git a/src/libjin/Filesystem/Filesystem.cpp b/src/libjin/Filesystem/Filesystem.cpp
index 3f91274..b8faed7 100644
--- a/src/libjin/Filesystem/Filesystem.cpp
+++ b/src/libjin/Filesystem/Filesystem.cpp
@@ -5,63 +5,63 @@
namespace jin
{
-namespace filesystem
-{
+ namespace filesystem
+ {
- Filesystem* Filesystem::fs = 0;
+ Filesystem* Filesystem::fs = 0;
- Filesystem::Filesystem()
- {
- S = smtnewshared();
- }
+ Filesystem::Filesystem()
+ {
+ S = smtnewshared();
+ }
- Filesystem* Filesystem::get()
- {
- return fs ? fs : (fs = new Filesystem());
- }
+ Filesystem* Filesystem::get()
+ {
+ return fs ? fs : (fs = new Filesystem());
+ }
- void Filesystem::mount(const char * path)
- {
- int err = smtmount(S, path);
- if (err)
- {
- printf("%s mounted path %s", smterrstr(err), path);
- exit(1);
- }
- }
+ void Filesystem::mount(const char * path)
+ {
+ int err = smtmount(S, path);
+ if (err)
+ {
+ printf("%s mounted path %s", smterrstr(err), path);
+ exit(1);
+ }
+ }
- int Filesystem::read(const char* path, Buffer* buffer)
- {
- buffer->data = smtread(S, path, &buffer->size);
- if (buffer->data == 0)
- return 0;
- return 1;
- }
+ int Filesystem::read(const char* path, Buffer* buffer)
+ {
+ buffer->data = smtread(S, path, &buffer->size);
+ if (buffer->data == 0)
+ return 0;
+ return 1;
+ }
- void* Filesystem::read(const char* path, unsigned int* len)
- {
- return smtread(S, path, len);
- }
+ void* Filesystem::read(const char* path, unsigned int* len)
+ {
+ return smtread(S, path, len);
+ }
- const char* Filesystem::getFull(const char* path)
- {
- return smtfullpath(S, path);
- }
+ const char* Filesystem::getFull(const char* path)
+ {
+ return smtfullpath(S, path);
+ }
- bool Filesystem::isDir(const char* path)
- {
- return smtisdir(S, path);
- }
+ bool Filesystem::isDir(const char* path)
+ {
+ return smtisdir(S, path);
+ }
- bool Filesystem::isFile(const char* path)
- {
- return smtisreg(S, path);
- }
+ bool Filesystem::isFile(const char* path)
+ {
+ return smtisreg(S, path);
+ }
- bool Filesystem::exists(const char* path)
- {
- return smtexists(S, path) == 0;
- }
+ bool Filesystem::exists(const char* path)
+ {
+ return smtexists(S, path) == 0;
+ }
-} // filesystem
+ } // filesystem
} // jin \ No newline at end of file
diff --git a/src/libjin/Filesystem/Filesystem.h b/src/libjin/Filesystem/Filesystem.h
index 3ae984d..b43d260 100644
--- a/src/libjin/Filesystem/Filesystem.h
+++ b/src/libjin/Filesystem/Filesystem.h
@@ -3,29 +3,29 @@
namespace jin
{
-namespace filesystem
-{
- /* Դ */
- class Filesystem
- {
- public:
- static Filesystem* get();
+ namespace filesystem
+ {
+ /* Դ */
+ class Filesystem
+ {
+ public:
+ static Filesystem* get();
- Filesystem();
+ Filesystem();
- bool isDir(const char* path);
- bool isFile(const char* path);
- bool exists(const char* path);
- int read(const char* path, Buffer* buffer);
- void* read(const char* path, unsigned int* len);
- void mount(const char* root);
- const char* getFull(const char* path);
+ bool isDir(const char* path);
+ bool isFile(const char* path);
+ bool exists(const char* path);
+ int read(const char* path, Buffer* buffer);
+ void* read(const char* path, unsigned int* len);
+ void mount(const char* root);
+ const char* getFull(const char* path);
- private:
- static Filesystem* fs;
- smtShared* S;
+ private:
+ static Filesystem* fs;
+ smtShared* S;
- };
+ };
-} // filesystem
+ } // filesystem
} // jin \ No newline at end of file