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 #include <storage/third_party_storage.h>
7 #include <common.h>
8 #include <vfs.h>
9 
10 struct FsStubNode;
11 
12 class NX_TEST_STORAGE_PLUGIN_API TestStorage :
13  public nx_spl::Storage,
14  public PluginRefCounter<TestStorage>
15 {
16 public:
17  TestStorage(const utils::VfsPair& vfsPair,
18  const std::string& prefix,
19  std::function<void()> onDestroyCb);
20  virtual ~TestStorage();
21 
22  virtual int STORAGE_METHOD_CALL isAvailable() const override;
23 
24  virtual nx_spl::IODevice* STORAGE_METHOD_CALL open(
25  const char* url,
26  int flags,
27  int* ecode
28  ) const override;
29 
30  virtual uint64_t STORAGE_METHOD_CALL getFreeSpace(int* ecode) const override;
31 
32  virtual uint64_t STORAGE_METHOD_CALL getTotalSpace(int* ecode) const override;
33 
34  virtual int STORAGE_METHOD_CALL getCapabilities() const override;
35 
36  virtual void STORAGE_METHOD_CALL removeFile(
37  const char* url,
38  int* ecode
39  ) override;
40 
41  virtual void STORAGE_METHOD_CALL removeDir(
42  const char* url,
43  int* ecode
44  ) override;
45 
46  virtual void STORAGE_METHOD_CALL renameFile(
47  const char* oldUrl,
48  const char* newUrl,
49  int* ecode
50  ) override;
51 
52  virtual nx_spl::FileInfoIterator* STORAGE_METHOD_CALL getFileIterator(
53  const char* dirUrl,
54  int* ecode
55  ) const override;
56 
57  virtual int STORAGE_METHOD_CALL fileExists(
58  const char* url,
59  int* ecode
60  ) const override;
61 
62  virtual int STORAGE_METHOD_CALL dirExists(
63  const char* url,
64  int* ecode
65  ) const override;
66 
67  virtual uint64_t STORAGE_METHOD_CALL fileSize(
68  const char* url,
69  int* ecode
70  ) const override;
71 
72 public: // plugin interface implementation
73  virtual void* queryInterface(const nxpl::NX_GUID& interfaceID) override;
74 
75  virtual int addRef() const override;
76  virtual int releaseRef() const override;
77 
78 private:
79  virtual nx_spl::IODevice* createIODevice(const std::string& name,
80  int category,
81  int flags,
82  int64_t size,
83  int* ecode) const;
84 
85 private:
86  utils::VfsPair m_vfsPair;
87  const std::string m_prefix;
88  std::function<void()> m_onDestroyCb;
89 };
virtual int addRef() const =0
Increment reference counter.
Definition: common.h:17
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:16
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:12
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:16
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