nx_storage_sdk  1.0
Storage SDK
test_storage.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2 
3 #pragma once
4 
5 #include <functional>
6 
7 #include <common.h>
8 #include <vfs.h>
9 
10 #include <storage/third_party_storage.h>
11 
12 struct FsStubNode;
13 
14 class NX_PLUGIN_API TestStorage :
15  public nx_spl::Storage,
16  public PluginRefCounter<TestStorage>
17 {
18 public:
19  TestStorage(const utils::VfsPair& vfsPair,
20  const std::string& prefix,
21  std::function<void()> onDestroyCb);
22  virtual ~TestStorage();
23 
24  virtual int STORAGE_METHOD_CALL isAvailable() const override;
25 
26  virtual nx_spl::IODevice* STORAGE_METHOD_CALL open(
27  const char* url,
28  int flags,
29  int* ecode
30  ) const override;
31 
32  virtual uint64_t STORAGE_METHOD_CALL getFreeSpace(int* ecode) const override;
33 
34  virtual uint64_t STORAGE_METHOD_CALL getTotalSpace(int* ecode) const override;
35 
36  virtual int STORAGE_METHOD_CALL getCapabilities() const override;
37 
38  virtual void STORAGE_METHOD_CALL removeFile(
39  const char* url,
40  int* ecode
41  ) override;
42 
43  virtual void STORAGE_METHOD_CALL removeDir(
44  const char* url,
45  int* ecode
46  ) override;
47 
48  virtual void STORAGE_METHOD_CALL renameFile(
49  const char* oldUrl,
50  const char* newUrl,
51  int* ecode
52  ) override;
53 
54  virtual nx_spl::FileInfoIterator* STORAGE_METHOD_CALL getFileIterator(
55  const char* dirUrl,
56  int* ecode
57  ) const override;
58 
59  virtual int STORAGE_METHOD_CALL fileExists(
60  const char* url,
61  int* ecode
62  ) const override;
63 
64  virtual int STORAGE_METHOD_CALL dirExists(
65  const char* url,
66  int* ecode
67  ) const override;
68 
69  virtual uint64_t STORAGE_METHOD_CALL fileSize(
70  const char* url,
71  int* ecode
72  ) const override;
73 
74 public: // plugin interface implementation
75  virtual void* queryInterface(const nxpl::NX_GUID& interfaceID) override;
76 
77  virtual int addRef() const override;
78  virtual int releaseRef() const override;
79 
80 private:
81  virtual nx_spl::IODevice* createIODevice(const std::string& name,
82  int category,
83  int flags,
84  int64_t size,
85  int* ecode) const;
86 
87 private:
88  utils::VfsPair m_vfsPair;
89  const std::string m_prefix;
90  std::function<void()> m_onDestroyCb;
91 };
virtual int addRef() const =0
Increment reference counter.
Definition: common.h:14
File information iterator abstraction.
Definition: third_party_storage.h:138
virtual void * queryInterface(const nxpl::NX_GUID &interfaceID)=0
Cast to type, specified by interfaceID.
virtual int STORAGE_METHOD_CALL isAvailable() const =0
Definition: fs_stub.h:15
virtual int STORAGE_METHOD_CALL fileExists(const char *url, int *ecode) const =0
virtual FileInfoIterator *STORAGE_METHOD_CALL getFileIterator(const char *dirUrl, int *ecode) const =0
GUID of plugin interface.
Definition: plugin_api.h:26
Definition: test_storage.h:14
virtual uint64_t STORAGE_METHOD_CALL fileSize(const char *url, int *ecode) const =0
Storage abstraction.
Definition: third_party_storage.h:155
virtual uint64_t STORAGE_METHOD_CALL getFreeSpace(int *ecode) const =0
virtual void STORAGE_METHOD_CALL removeFile(const char *url, int *ecode)=0
virtual uint64_t STORAGE_METHOD_CALL getTotalSpace(int *ecode) const =0
virtual int STORAGE_METHOD_CALL getCapabilities() const =0
virtual IODevice *STORAGE_METHOD_CALL open(const char *url, int flags, int *ecode) const =0
virtual void STORAGE_METHOD_CALL removeDir(const char *url, int *ecode)=0
virtual void STORAGE_METHOD_CALL renameFile(const char *oldUrl, const char *newUrl, int *ecode)=0
Definition: vfs.h:17
virtual int releaseRef() const =0
Decrement reference counter.
virtual int STORAGE_METHOD_CALL dirExists(const char *url, int *ecode) const =0
IO device abstraction.
Definition: third_party_storage.h:73