Diligent Engine API Reference
UWPFileSystem.h
1 /* Copyright 2015-2016 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 "BasicFileSystem.h"
27 #include "DataBlob.h"
28 #include <memory>
29 
30 // Do not include windows headers here as they will mess up CreateDirectory()
31 // and DeleteFile() functions!
32 //#define NOMINMAX
33 //#include <wrl.h>
34 
35 class WindowsStoreFile : public BasicFile
36 {
37 public:
38  WindowsStoreFile( const FileOpenAttribs &OpenAttribs );
39  ~WindowsStoreFile();
40 
41  void Read( Diligent::IDataBlob *pData );
42 
43  bool Read( void *Data, size_t BufferSize );
44 
45  void Write( Diligent::IDataBlob *pData );
46  bool Write( const void *Data, size_t BufferSize );
47 
48  size_t GetSize();
49 
50  size_t GetPos();
51 
52  void SetPos(size_t Offset, FilePosOrigin Origin);
53 
54 private:
55  // We have to do such tricks, because we cannot #include <wrl.h>
56  // to avoid name clashes.
57  std::unique_ptr<class FileHandleWrapper> m_FileHandle;
58 };
59 
60 struct WindowsStoreFileSystem : public BasicFileSystem
61 {
62 public:
63  static WindowsStoreFile* OpenFile( const FileOpenAttribs &OpenAttribs );
64  static inline Diligent::Char GetSlashSymbol(){ return '\\'; }
65 
66  static bool FileExists( const Diligent::Char *strFilePath );
67  static bool PathExists( const Diligent::Char *strPath );
68 
69  static bool CreateDirectory( const Diligent::Char *strPath );
70  static void ClearDirectory( const Diligent::Char *strPath );
71  static void DeleteFile( const Diligent::Char *strPath );
72  static std::vector<std::unique_ptr<FindFileData>> Search(const Diligent::Char *SearchPattern);
73 };
Base interface for a file stream.
Definition: DataBlob.h:39