1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2017 by Michael Sevakis
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef RB_NAMESPACE_H
#define RB_NAMESPACE_H
#include "file_internal.h"
enum ns_item_flags
{
NSITEM_MOUNTED = 0x01, /* item is mounted */
NSITEM_HIDDEN = 0x02, /* item is not enumerated */
NSITEM_CONTENTS = 0x04, /* contents enumerate */
};
struct ns_scan_info
{
struct dirscan_info scan; /* dirscan info - first! */
int item; /* current item in parent */
};
/* root functions */
#define ROOT_MAX_REALPATH 80
const char* root_get_realpath(void);
int root_mount_path(const char *path, unsigned int flags);
void root_unmount_volume(IF_MV_NONVOID(int volume));
int root_readdir_dirent(struct filestr_base *stream,
struct ns_scan_info *scanp,
struct DIRENT *entry);
/* namespace functions */
int ns_parse_root(const char *path, const char **pathp, uint16_t *lenp);
int ns_open_root(IF_MV(int volume,) unsigned int *callflagsp,
struct file_base_info *infop, uint16_t *attrp);
int ns_open_stream(const char *path, unsigned int callflags,
struct filestr_base *stream, struct ns_scan_info *scanp);
bool ns_volume_is_visible(IF_MV_NONVOID(int volume));
/* closes the namespace stream */
static inline int ns_close_stream(struct filestr_base *stream)
{
return close_stream_internal(stream);
}
#include "dircache_redirect.h"
static inline void ns_dirscan_rewind(struct ns_scan_info *scanp)
{
rewinddir_dirent(&scanp->scan);
if (scanp->item != -1)
scanp->item = 0;
}
static inline int ns_readdir_dirent(struct filestr_base *stream,
struct ns_scan_info *scanp,
struct dirent *entry)
{
if (scanp->item == -1)
return readdir_dirent(stream, &scanp->scan, entry);
else
return root_readdir_dirent(stream, scanp, entry);
}
#endif /* RB_NAMESPACE_H */
|