Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Platforms/Basic/interface/BasicFileSystem.h Source File

Diligent Engine API Reference

BasicFileSystem.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
26 #include <vector>
27 #include "BasicTypes.h"
28
29 enum class EFileAccessMode
30 {
31 Read,
32 Overwrite,
33 Append
34 };
35
36 enum class FilePosOrigin
37 {
38 Start,
39 Curr,
40 End
41 };
42
43
44 struct FileOpenAttribs
45 {
46 const Diligent::Char *strFilePath;
47 EFileAccessMode AccessMode;
48 FileOpenAttribs(const Diligent::Char *Path = nullptr,
49 EFileAccessMode Access = EFileAccessMode::Read) :
50 strFilePath( Path ),
51 AccessMode( Access )
52 {}
53 };
54
55 class BasicFile
56 {
57 public:
58 BasicFile( const FileOpenAttribs &OpenAttribs, Diligent::Char SlashSymbol );
59 virtual ~BasicFile();
60
61 size_t GetSize();
62
63 const Diligent::String& GetPath(){ return m_Path; }
64
65 protected:
66 Diligent::String GetOpenModeStr();
67
68 FileOpenAttribs m_OpenAttribs;
69 Diligent::String m_Path;
70 };
71
72 struct FindFileData
73 {
74 virtual const Diligent::Char* Name()const = 0;
75 virtual bool IsDirectory()const = 0;
76
77 virtual ~FindFileData(){}
78 };
79
80 struct BasicFileSystem
81 {
82 public:
83 static BasicFile* OpenFile( FileOpenAttribs &OpenAttribs );
84 static void ReleaseFile( BasicFile* );
85
86 static std::string GetFullPath( const Diligent::Char *strFilePath );
87
88 static bool FileExists( const Diligent::Char *strFilePath );
89
90 static void SetWorkingDirectory( const Diligent::Char *strWorkingDir ){ m_strWorkingDirectory = strWorkingDir; }
91 static const Diligent::String &GetWorkingDirectory(){ return m_strWorkingDirectory; }
92
93 static Diligent::Char GetSlashSymbol();
94 static void CorrectSlashes(Diligent::String &Path, Diligent::Char SlashSymbol);
95
96 static void SplitFilePath(const Diligent::String& FullName,
97 Diligent::String *Path,
98 Diligent::String *Name);
99
100 protected:
101 static Diligent::String m_strWorkingDirectory;
102 };
Diligent::String
std::basic_string< Char > String
String variable.
Definition: BasicTypes.h:51