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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_DIRHANDLE_H
#define MBED_DIRHANDLE_H
#include <stdint.h>
#include "platform/platform.h"
#include "FileHandle.h"
namespace mbed {
/** \addtogroup drivers */
/** @{*/
/** Represents a directory stream. Objects of this type are returned
* by a FileSystemLike's opendir method. Implementations must define
* at least closedir, readdir and rewinddir.
*
* If a FileSystemLike class defines the opendir method, then the
* directories of an object of that type can be accessed by
* DIR *d = opendir("/example/directory") (or opendir("/example")
* to open the root of the filesystem), and then using readdir(d) etc.
*
* The root directory is considered to contain all FileLike and
* FileSystemLike objects, so the DIR* returned by opendir("/") will
* reflect this.
*
* @Note Synchronization level: Set by subclass
*/
class DirHandle {
public:
MBED_DEPRECATED_SINCE("mbed-os-5.4",
"The mbed 2 filesystem classes have been superseeded by the FileSystem api, "
"Replaced by File")
DirHandle() {}
/** Closes the directory.
*
* @returns
* 0 on success,
* -1 on error.
*/
virtual int closedir()=0;
/** Return the directory entry at the current position, and
* advances the position to the next entry.
*
* @returns
* A pointer to a dirent structure representing the
* directory entry at the current position, or NULL on reaching
* end of directory or error.
*/
virtual struct dirent *readdir()=0;
/** Resets the position to the beginning of the directory.
*/
virtual void rewinddir()=0;
/** Returns the current position of the DirHandle.
*
* @returns
* the current position,
* -1 on error.
*/
virtual off_t telldir() { return -1; }
/** Sets the position of the DirHandle.
*
* @param location The location to seek to. Must be a value returned by telldir.
*/
virtual void seekdir(off_t location) { (void)location;}
virtual ~DirHandle() {}
protected:
/** Acquire exclusive access to this object.
*/
virtual void lock() {
// Stub
}
/** Release exclusive access to this object.
*/
virtual void unlock() {
// Stub
}
protected:
/** Internal-only constructor to work around deprecated notices when not used
*. due to nested deprecations and difficulty of compilers finding their way around
* the class hierarchy
*/
friend class FileSystemLike;
DirHandle(int) {}
};
} // namespace mbed
#endif /* MBED_DIRHANDLE_H */
/** @}*/
|