]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/api/DirHandle.h
1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef MBED_DIRHANDLE_H
17 #define MBED_DIRHANDLE_H
19 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
24 # include <sys/syslimits.h>
27 #include "FileHandle.h"
30 char d_name
[NAME_MAX
+1];
35 /** Represents a directory stream. Objects of this type are returned
36 * by a FileSystemLike's opendir method. Implementations must define
37 * at least closedir, readdir and rewinddir.
39 * If a FileSystemLike class defines the opendir method, then the
40 * directories of an object of that type can be accessed by
41 * DIR *d = opendir("/example/directory") (or opendir("/example")
42 * to open the root of the filesystem), and then using readdir(d) etc.
44 * The root directory is considered to contain all FileLike and
45 * FileSystemLike objects, so the DIR* returned by opendir("/") will
51 /** Closes the directory.
57 virtual int closedir()=0;
59 /** Return the directory entry at the current position, and
60 * advances the position to the next entry.
63 * A pointer to a dirent structure representing the
64 * directory entry at the current position, or NULL on reaching
65 * end of directory or error.
67 virtual struct dirent
*readdir()=0;
69 /** Resets the position to the beginning of the directory.
71 virtual void rewinddir()=0;
73 /** Returns the current position of the DirHandle.
76 * the current position,
79 virtual off_t
telldir() { return -1; }
81 /** Sets the position of the DirHandle.
83 * @param location The location to seek to. Must be a value returned by telldir.
85 virtual void seekdir(off_t location
) { }
87 virtual ~DirHandle() {}
92 typedef mbed::DirHandle
DIR;
95 DIR *opendir(const char*);
96 struct dirent
*readdir(DIR *);
100 void seekdir(DIR*, long);
101 int mkdir(const char *name
, mode_t n
);
104 #endif /* MBED_DIRHANDLE_H */