blob: f7e6339344aa188b5ff6dbb803cee2839b10d74c (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#ifndef __JE_ASSET_DATABASE_H__
#define __JE_ASSET_DATABASE_H__
#include "../core/configuration.h"
#if defined(jin_filesystem)
#include <vector>
#include "smount/smount.h"
#include "buffer.h"
namespace JinEngine
{
namespace Filesystem
{
///
/// Assets managment.
///
class AssetDatabase : public Object
{
public:
///
/// Get asset database singleton.
///
/// @param Singleton of asset database.
///
static AssetDatabase* get();
///
/// Asset database constructor.
///
AssetDatabase();
///
/// Set asset root folder.
///
/// @param root Root folder of assets.
///
void mount(const char* root);
///
/// Check if the path is directory.
///
/// @param path Path under asset folder.
/// @return True if the given path is directory, otherwise return false.
///
bool isDir(const char* path);
///
/// Check if the path is file.
///
/// @param path Path under asset folder.
/// @return True if the given path is file, otherwise return false.
///
bool isFile(const char* path);
///
/// Check if the path exists.
/// @param path Given path.
/// @return True if path exists, otherwise return false.
///
bool exists(const char* path);
///
/// Read file into a buffer.
///
/// @param path Path of file.
/// @param buffer Buffer to fill.
/// @return True if read sucessful, otherwise return false.
///
void read(const char* path, Buffer& buffer);
///
/// Read file and return data content.
///
/// @param path Path of file.
/// @param length Length of data.
/// @return Data if read sucessful, otherwise return null.
///
void* read(const char* path, unsigned int* length);
///
/// Get files under given directory.
///
/// @param path Path of directory.
/// @param recursive Recursivily search folder.
/// @return File list under given directory.
///
std::vector<std::string> getFiles(const char* directory, bool recursive = false);
///
/// Get full path of asset.
///
/// @param path Path of asset.
/// @return Full path of asset.
///
const char* getFull(const char* path);
private:
static AssetDatabase* mAssetDatabase;
#if jin_filesystem == jin_filesystem_smount
smtShared* mSmt;
#endif
};
} // namespace Filesystem
} // namespace JinEngine
#endif // jin_filesystem
#endif
|