blob: e9b05e38ed9021d6fa0edc56c656958f08ac9cdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#include "filesystem.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h> /* defines FILENAME_MAX */
namespace jin
{
namespace filesystem
{
Filesystem* Filesystem::fs = 0;
Filesystem::Filesystem()
{
S = smtnewshared();
}
Filesystem* Filesystem::get()
{
return fs ? fs : (fs = new Filesystem());
}
/**
* r is relative path
*/
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;
}
const char* Filesystem::getFull(const char* path)
{
return smtfullpath(S, path);
}
bool Filesystem::isDir(const char* path)
{
return smtisdir(S, path);
}
bool Filesystem::isFile(const char* path)
{
return smtisreg(S, path);
}
bool Filesystem::exists(const char* path)
{
return smtexists(S, path) == 0;
}
}
}
|