nx_storage_sdk  1.0
Storage SDK
fs_stub.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 <stddef.h>
6 #include <stdint.h>
7 
8 #include <common.h>
9 
10 enum FsStubEntryType
11 {
12  dir = 1,
13  file = 2
14 };
15 
16 struct FsStubNode
17 {
18  char *name;
19  int mask;
20  enum FsStubEntryType type;
21  int64_t size;
22  struct FsStubNode *next;
23  struct FsStubNode *prev;
24  struct FsStubNode *parent;
25  struct FsStubNode *child;
26 };
27 
28 struct FsStubNode *fsStubCreateTopLevel();
29 struct FsStubNode *FsStubNode_add(
30  struct FsStubNode *parent,
31  const char *path,
32  int type,
33  int mask,
34  int64_t size);
35 
36 void FsStubNode_forEach(
37  struct FsStubNode *root,
38  void *ctx,
39  void (*action)(void *ctx, struct FsStubNode *node));
40 
41 /* places full path for the node into the buf if buf size is enough, returns buffer size needed */
42 int FsStubNode_fullPath(struct FsStubNode *fsNode, char *buf, int size);
43 
44 NX_PLUGIN_API struct FsStubNode *FsStubNode_find(struct FsStubNode *topLevelNode, const char *path);
45 int FsStubNode_rename(struct FsStubNode *fsNode, const char *newName);
46 void FsStubNode_remove(struct FsStubNode *fsNode);
47 
Definition: fs_stub.h:16