Kiwano Engine v1.3.x
FileSystem.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/core/Resource.h>
23
24namespace kiwano
25{
30class KGE_API FileSystem : public Singleton<FileSystem>
31{
33
34public:
40 void AddSearchPath(StringView path);
41
47 void SetSearchPaths(const Vector<String>& paths);
48
55 String GetFullPathForFile(StringView file) const;
56
63 String GetFileExt(StringView file) const;
64
71 void AddFileLookupRule(StringView key, StringView file_path);
72
78 void SetFileLookupDictionary(const UnorderedMap<String, String>& dict);
79
84 void ReadFile(StringView file_path, std::vector<uint8_t>& output);
85
92 bool IsFileExists(StringView file_path) const;
93
100 bool IsAbsolutePath(StringView path) const;
101
108 bool RemoveFile(StringView file_path) const;
109
117 bool ExtractResourceToFile(const Resource& res, StringView dest_file_name) const;
118
119 ~FileSystem();
120
121private:
122 FileSystem();
123
124private:
125 Vector<String> search_paths_;
126 UnorderedMap<String, String> file_lookup_dict_;
127 mutable UnorderedMap<String, String> file_lookup_cache_;
128};
129} // namespace kiwano
文件系统,为其他模块提供文件搜索规则等
Definition: FileSystem.h:31
资源
Definition: Resource.h:41
Definition: Singleton.h:28