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
86 bool IsFileExists(StringView file_path) const;
87
94 bool IsAbsolutePath(StringView path) const;
95
102 bool RemoveFile(StringView file_path) const;
103
111 bool ExtractResourceToFile(const Resource& res, StringView dest_file_name) const;
112
113 ~FileSystem();
114
115private:
116 FileSystem();
117
118private:
119 Vector<String> search_paths_;
120 UnorderedMap<String, String> file_lookup_dict_;
121 mutable UnorderedMap<String, String> file_lookup_cache_;
122};
123} // namespace kiwano
文件系统,为其他模块提供文件搜索规则等
Definition: FileSystem.h:31
资源
Definition: Resource.h:41
Definition: Singleton.h:28