This is the final version of Mini Gateway for Automation and Security desgined for Renesas GR Peach Design Contest

Dependencies:   GR-PEACH_video GraphicsFramework HTTPServer R_BSP mbed-rpc mbed-rtos Socket lwip-eth lwip-sys lwip FATFileSystem

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
vipinranka
Date:
Wed Jan 11 11:41:30 2017 +0000
Revision:
12:9a20164dcc47
This is the final version MGAS Project for Renesas GR Peach Design Contest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vipinranka 12:9a20164dcc47 1 /* mbed Microcontroller Library
vipinranka 12:9a20164dcc47 2 * Copyright (c) 2006-2013 ARM Limited
vipinranka 12:9a20164dcc47 3 *
vipinranka 12:9a20164dcc47 4 * Licensed under the Apache License, Version 2.0 (the "License");
vipinranka 12:9a20164dcc47 5 * you may not use this file except in compliance with the License.
vipinranka 12:9a20164dcc47 6 * You may obtain a copy of the License at
vipinranka 12:9a20164dcc47 7 *
vipinranka 12:9a20164dcc47 8 * http://www.apache.org/licenses/LICENSE-2.0
vipinranka 12:9a20164dcc47 9 *
vipinranka 12:9a20164dcc47 10 * Unless required by applicable law or agreed to in writing, software
vipinranka 12:9a20164dcc47 11 * distributed under the License is distributed on an "AS IS" BASIS,
vipinranka 12:9a20164dcc47 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
vipinranka 12:9a20164dcc47 13 * See the License for the specific language governing permissions and
vipinranka 12:9a20164dcc47 14 * limitations under the License.
vipinranka 12:9a20164dcc47 15 */
vipinranka 12:9a20164dcc47 16 #ifndef MBED_DIRHANDLE_H
vipinranka 12:9a20164dcc47 17 #define MBED_DIRHANDLE_H
vipinranka 12:9a20164dcc47 18
vipinranka 12:9a20164dcc47 19 #if defined(__ARMCC_VERSION) || defined(__ICCARM__)
vipinranka 12:9a20164dcc47 20 # define NAME_MAX 255
vipinranka 12:9a20164dcc47 21 typedef int mode_t;
vipinranka 12:9a20164dcc47 22
vipinranka 12:9a20164dcc47 23 #else
vipinranka 12:9a20164dcc47 24 # include <sys/syslimits.h>
vipinranka 12:9a20164dcc47 25 #endif
vipinranka 12:9a20164dcc47 26
vipinranka 12:9a20164dcc47 27 #include "FileHandle.h"
vipinranka 12:9a20164dcc47 28
vipinranka 12:9a20164dcc47 29 struct dirent {
vipinranka 12:9a20164dcc47 30 char d_name[NAME_MAX+1];
vipinranka 12:9a20164dcc47 31 };
vipinranka 12:9a20164dcc47 32
vipinranka 12:9a20164dcc47 33 namespace mbed {
vipinranka 12:9a20164dcc47 34 /** \addtogroup drivers */
vipinranka 12:9a20164dcc47 35 /** @{*/
vipinranka 12:9a20164dcc47 36
vipinranka 12:9a20164dcc47 37 /** Represents a directory stream. Objects of this type are returned
vipinranka 12:9a20164dcc47 38 * by a FileSystemLike's opendir method. Implementations must define
vipinranka 12:9a20164dcc47 39 * at least closedir, readdir and rewinddir.
vipinranka 12:9a20164dcc47 40 *
vipinranka 12:9a20164dcc47 41 * If a FileSystemLike class defines the opendir method, then the
vipinranka 12:9a20164dcc47 42 * directories of an object of that type can be accessed by
vipinranka 12:9a20164dcc47 43 * DIR *d = opendir("/example/directory") (or opendir("/example")
vipinranka 12:9a20164dcc47 44 * to open the root of the filesystem), and then using readdir(d) etc.
vipinranka 12:9a20164dcc47 45 *
vipinranka 12:9a20164dcc47 46 * The root directory is considered to contain all FileLike and
vipinranka 12:9a20164dcc47 47 * FileSystemLike objects, so the DIR* returned by opendir("/") will
vipinranka 12:9a20164dcc47 48 * reflect this.
vipinranka 12:9a20164dcc47 49 *
vipinranka 12:9a20164dcc47 50 * @Note Synchronization level: Set by subclass
vipinranka 12:9a20164dcc47 51 */
vipinranka 12:9a20164dcc47 52 class DirHandle {
vipinranka 12:9a20164dcc47 53
vipinranka 12:9a20164dcc47 54 public:
vipinranka 12:9a20164dcc47 55 /** Closes the directory.
vipinranka 12:9a20164dcc47 56 *
vipinranka 12:9a20164dcc47 57 * @returns
vipinranka 12:9a20164dcc47 58 * 0 on success,
vipinranka 12:9a20164dcc47 59 * -1 on error.
vipinranka 12:9a20164dcc47 60 */
vipinranka 12:9a20164dcc47 61 virtual int closedir()=0;
vipinranka 12:9a20164dcc47 62
vipinranka 12:9a20164dcc47 63 /** Return the directory entry at the current position, and
vipinranka 12:9a20164dcc47 64 * advances the position to the next entry.
vipinranka 12:9a20164dcc47 65 *
vipinranka 12:9a20164dcc47 66 * @returns
vipinranka 12:9a20164dcc47 67 * A pointer to a dirent structure representing the
vipinranka 12:9a20164dcc47 68 * directory entry at the current position, or NULL on reaching
vipinranka 12:9a20164dcc47 69 * end of directory or error.
vipinranka 12:9a20164dcc47 70 */
vipinranka 12:9a20164dcc47 71 virtual struct dirent *readdir()=0;
vipinranka 12:9a20164dcc47 72
vipinranka 12:9a20164dcc47 73 /** Resets the position to the beginning of the directory.
vipinranka 12:9a20164dcc47 74 */
vipinranka 12:9a20164dcc47 75 virtual void rewinddir()=0;
vipinranka 12:9a20164dcc47 76
vipinranka 12:9a20164dcc47 77 /** Returns the current position of the DirHandle.
vipinranka 12:9a20164dcc47 78 *
vipinranka 12:9a20164dcc47 79 * @returns
vipinranka 12:9a20164dcc47 80 * the current position,
vipinranka 12:9a20164dcc47 81 * -1 on error.
vipinranka 12:9a20164dcc47 82 */
vipinranka 12:9a20164dcc47 83 virtual off_t telldir() { return -1; }
vipinranka 12:9a20164dcc47 84
vipinranka 12:9a20164dcc47 85 /** Sets the position of the DirHandle.
vipinranka 12:9a20164dcc47 86 *
vipinranka 12:9a20164dcc47 87 * @param location The location to seek to. Must be a value returned by telldir.
vipinranka 12:9a20164dcc47 88 */
vipinranka 12:9a20164dcc47 89 virtual void seekdir(off_t location) { (void)location;}
vipinranka 12:9a20164dcc47 90
vipinranka 12:9a20164dcc47 91 virtual ~DirHandle() {}
vipinranka 12:9a20164dcc47 92
vipinranka 12:9a20164dcc47 93 protected:
vipinranka 12:9a20164dcc47 94
vipinranka 12:9a20164dcc47 95 /** Acquire exclusive access to this object.
vipinranka 12:9a20164dcc47 96 */
vipinranka 12:9a20164dcc47 97 virtual void lock() {
vipinranka 12:9a20164dcc47 98 // Stub
vipinranka 12:9a20164dcc47 99 }
vipinranka 12:9a20164dcc47 100
vipinranka 12:9a20164dcc47 101 /** Release exclusive access to this object.
vipinranka 12:9a20164dcc47 102 */
vipinranka 12:9a20164dcc47 103 virtual void unlock() {
vipinranka 12:9a20164dcc47 104 // Stub
vipinranka 12:9a20164dcc47 105 }
vipinranka 12:9a20164dcc47 106 };
vipinranka 12:9a20164dcc47 107
vipinranka 12:9a20164dcc47 108 } // namespace mbed
vipinranka 12:9a20164dcc47 109
vipinranka 12:9a20164dcc47 110 typedef mbed::DirHandle DIR;
vipinranka 12:9a20164dcc47 111
vipinranka 12:9a20164dcc47 112 extern "C" {
vipinranka 12:9a20164dcc47 113 DIR *opendir(const char*);
vipinranka 12:9a20164dcc47 114 struct dirent *readdir(DIR *);
vipinranka 12:9a20164dcc47 115 int closedir(DIR*);
vipinranka 12:9a20164dcc47 116 void rewinddir(DIR*);
vipinranka 12:9a20164dcc47 117 long telldir(DIR*);
vipinranka 12:9a20164dcc47 118 void seekdir(DIR*, long);
vipinranka 12:9a20164dcc47 119 int mkdir(const char *name, mode_t n);
vipinranka 12:9a20164dcc47 120 };
vipinranka 12:9a20164dcc47 121
vipinranka 12:9a20164dcc47 122 #endif /* MBED_DIRHANDLE_H */
vipinranka 12:9a20164dcc47 123
vipinranka 12:9a20164dcc47 124 /** @}*/