Diligent Engine  v.2.4.g
UWPFileSystem.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
30 #include <memory>
31 
32 #include "../../Basic/interface/BasicFileSystem.hpp"
33 #include "../../../Primitives/interface/DataBlob.h"
34 
35 // Do not include windows headers here as they will mess up CreateDirectory()
36 // and DeleteFile() functions!
37 //#define NOMINMAX
38 //#include <wrl.h>
39 
41 {
42 public:
43  WindowsStoreFile(const FileOpenAttribs& OpenAttribs);
45 
46  void Read(Diligent::IDataBlob* pData);
47 
48  bool Read(void* Data, size_t BufferSize);
49 
50  void Write(Diligent::IDataBlob* pData);
51  bool Write(const void* Data, size_t BufferSize);
52 
53  size_t GetSize();
54 
55  size_t GetPos();
56 
57  void SetPos(size_t Offset, FilePosOrigin Origin);
58 
59 private:
60  // We have to do such tricks, because we cannot #include <wrl.h>
61  // to avoid name clashes.
62  std::unique_ptr<class FileHandleWrapper> m_FileHandle;
63 };
64 
66 {
67 public:
68  static WindowsStoreFile* OpenFile(const FileOpenAttribs& OpenAttribs);
69 
70  static inline Diligent::Char GetSlashSymbol() { return '\\'; }
71 
72  static bool FileExists(const Diligent::Char* strFilePath);
73  static bool PathExists(const Diligent::Char* strPath);
74 
75  static bool CreateDirectory(const Diligent::Char* strPath);
76  static void ClearDirectory(const Diligent::Char* strPath);
77  static void DeleteFile(const Diligent::Char* strPath);
78 
79  static std::vector<std::unique_ptr<FindFileData>> Search(const Diligent::Char* SearchPattern);
80 };
Diligent::Char
char Char
Definition: BasicTypes.h:64
FileOpenAttribs
Definition: BasicFileSystem.hpp:48
Diligent::IDataBlob
Base interface for a file stream.
Definition: DataBlob.h:52
WindowsStoreFileSystem::Search
static std::vector< std::unique_ptr< FindFileData > > Search(const Diligent::Char *SearchPattern)
Definition: UWPFileSystem.cpp:273
WindowsStoreFile
Definition: UWPFileSystem.hpp:40
WindowsStoreFileSystem::DeleteFile
static void DeleteFile(const Diligent::Char *strPath)
Definition: UWPFileSystem.cpp:45
WindowsStoreFile::Write
void Write(Diligent::IDataBlob *pData)
Definition: UWPFileSystem.cpp:168
WindowsStoreFileSystem::ClearDirectory
static void ClearDirectory(const Diligent::Char *strPath)
Definition: UWPFileSystem.cpp:256
WindowsStoreFile::Read
void Read(Diligent::IDataBlob *pData)
Definition: UWPFileSystem.cpp:158
FilePosOrigin
FilePosOrigin
Definition: BasicFileSystem.hpp:40
WindowsStoreFile::~WindowsStoreFile
~WindowsStoreFile()
Definition: UWPFileSystem.cpp:118
WindowsStoreFileSystem::FileExists
static bool FileExists(const Diligent::Char *strFilePath)
Definition: UWPFileSystem.cpp:215
WindowsStoreFileSystem::OpenFile
static WindowsStoreFile * OpenFile(const FileOpenAttribs &OpenAttribs)
Definition: UWPFileSystem.cpp:201
WindowsStoreFileSystem::PathExists
static bool PathExists(const Diligent::Char *strPath)
Definition: UWPFileSystem.cpp:250
WindowsStoreFileSystem::GetSlashSymbol
static Diligent::Char GetSlashSymbol()
Definition: UWPFileSystem.hpp:70
WindowsStoreFileSystem::CreateDirectory
static bool CreateDirectory(const Diligent::Char *strPath)
Definition: UWPFileSystem.cpp:38
BasicFileSystem
Definition: BasicFileSystem.hpp:82
WindowsStoreFile::SetPos
void SetPos(size_t Offset, FilePosOrigin Origin)
Definition: UWPFileSystem.cpp:195
WindowsStoreFile::GetPos
size_t GetPos()
Definition: UWPFileSystem.cpp:189
WindowsStoreFile::GetSize
size_t GetSize()
Definition: UWPFileSystem.cpp:138
WindowsStoreFileSystem
Definition: UWPFileSystem.hpp:65
BasicFile
Definition: BasicFileSystem.hpp:59
WindowsStoreFile::WindowsStoreFile
WindowsStoreFile(const FileOpenAttribs &OpenAttribs)
Definition: UWPFileSystem.cpp:63