1 /* mbed Microcontroller Library - DirHandler
2 * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
5 #ifndef MBED_DIRHANDLE_H
6 #define MBED_DIRHANDLE_H
12 # include <sys/syslimits.h>
14 #include "FileHandle.h"
17 char d_name
[NAME_MAX
+1];
23 * Represents a directory stream. Objects of this type are returned
24 * by a FileSystemLike's opendir method. Implementations must define
25 * at least closedir, readdir and rewinddir.
27 * If a FileSystemLike class defines the opendir method, then the
28 * directories of an object of that type can be accessed by
29 * DIR *d = opendir("/example/directory") (or opendir("/example")
30 * to open the root of the filesystem), and then using readdir(d) etc.
32 * The root directory is considered to contain all FileLike and
33 * FileSystemLike objects, so the DIR* returned by opendir("/") will
40 * Closes the directory.
43 * returns - 0 on success, or -1 on error.
45 virtual int closedir()=0;
48 * Return the directory entry at the current position, and
49 * advances the position to the next entry.
52 * A pointer to a dirent structure representing the
53 * directory entry at the current position, or NULL on reaching
54 * end of directory or error.
56 virtual struct dirent
*readdir()=0;
59 * Resets the position to the beginning of the directory.
61 virtual void rewinddir()=0;
64 * Returns the current position of the DirHandle.
67 * The current position, or -1 on error.
69 virtual off_t
telldir() { return -1; }
72 * Sets the position of the DirHandle.
75 * location - The location to seek to. Must be a value returned
78 virtual void seekdir(off_t location
) { }
84 typedef mbed::DirHandle
DIR;
87 DIR *opendir(const char*);
88 struct dirent
*readdir(DIR *);
92 void seekdir(DIR*, long);
93 int mkdir(const char *name
, mode_t n
);
96 #endif /* MBED_DIRHANDLE_H */