Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /* mbed Microcontroller Library
sahilmgandhi 18:6a4db94011d3 2 * Copyright (c) 2006-2013 ARM Limited
sahilmgandhi 18:6a4db94011d3 3 *
sahilmgandhi 18:6a4db94011d3 4 * Licensed under the Apache License, Version 2.0 (the "License");
sahilmgandhi 18:6a4db94011d3 5 * you may not use this file except in compliance with the License.
sahilmgandhi 18:6a4db94011d3 6 * You may obtain a copy of the License at
sahilmgandhi 18:6a4db94011d3 7 *
sahilmgandhi 18:6a4db94011d3 8 * http://www.apache.org/licenses/LICENSE-2.0
sahilmgandhi 18:6a4db94011d3 9 *
sahilmgandhi 18:6a4db94011d3 10 * Unless required by applicable law or agreed to in writing, software
sahilmgandhi 18:6a4db94011d3 11 * distributed under the License is distributed on an "AS IS" BASIS,
sahilmgandhi 18:6a4db94011d3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sahilmgandhi 18:6a4db94011d3 13 * See the License for the specific language governing permissions and
sahilmgandhi 18:6a4db94011d3 14 * limitations under the License.
sahilmgandhi 18:6a4db94011d3 15 */
sahilmgandhi 18:6a4db94011d3 16 #ifndef MBED_FILESYSTEMLIKE_H
sahilmgandhi 18:6a4db94011d3 17 #define MBED_FILESYSTEMLIKE_H
sahilmgandhi 18:6a4db94011d3 18
sahilmgandhi 18:6a4db94011d3 19 #include "platform/platform.h"
sahilmgandhi 18:6a4db94011d3 20
sahilmgandhi 18:6a4db94011d3 21 #include "drivers/FileBase.h"
sahilmgandhi 18:6a4db94011d3 22 #include "drivers/FileHandle.h"
sahilmgandhi 18:6a4db94011d3 23 #include "drivers/DirHandle.h"
sahilmgandhi 18:6a4db94011d3 24
sahilmgandhi 18:6a4db94011d3 25 namespace mbed {
sahilmgandhi 18:6a4db94011d3 26 /** \addtogroup drivers */
sahilmgandhi 18:6a4db94011d3 27 /** @{*/
sahilmgandhi 18:6a4db94011d3 28
sahilmgandhi 18:6a4db94011d3 29 /** A filesystem-like object is one that can be used to open files
sahilmgandhi 18:6a4db94011d3 30 * though it by fopen("/name/filename", mode)
sahilmgandhi 18:6a4db94011d3 31 *
sahilmgandhi 18:6a4db94011d3 32 * Implementations must define at least open (the default definitions
sahilmgandhi 18:6a4db94011d3 33 * of the rest of the functions just return error values).
sahilmgandhi 18:6a4db94011d3 34 *
sahilmgandhi 18:6a4db94011d3 35 * @Note Synchronization level: Set by subclass
sahilmgandhi 18:6a4db94011d3 36 */
sahilmgandhi 18:6a4db94011d3 37 class FileSystemLike : public FileBase {
sahilmgandhi 18:6a4db94011d3 38
sahilmgandhi 18:6a4db94011d3 39 public:
sahilmgandhi 18:6a4db94011d3 40 /** FileSystemLike constructor
sahilmgandhi 18:6a4db94011d3 41 *
sahilmgandhi 18:6a4db94011d3 42 * @param name The name to use for the filesystem.
sahilmgandhi 18:6a4db94011d3 43 */
sahilmgandhi 18:6a4db94011d3 44 MBED_DEPRECATED_SINCE("mbed-os-5.4",
sahilmgandhi 18:6a4db94011d3 45 "The mbed 2 filesystem classes have been superseeded by the FileSystem api, "
sahilmgandhi 18:6a4db94011d3 46 "Replaced by FileSystem")
sahilmgandhi 18:6a4db94011d3 47 FileSystemLike(const char *name);
sahilmgandhi 18:6a4db94011d3 48
sahilmgandhi 18:6a4db94011d3 49 virtual ~FileSystemLike();
sahilmgandhi 18:6a4db94011d3 50
sahilmgandhi 18:6a4db94011d3 51 MBED_DEPRECATED_SINCE("mbed-os-5.4",
sahilmgandhi 18:6a4db94011d3 52 "The mbed 2 filesystem classes have been superseeded by the FileSystem api, "
sahilmgandhi 18:6a4db94011d3 53 "Replaced by FileSystem")
sahilmgandhi 18:6a4db94011d3 54 static DirHandle *opendir();
sahilmgandhi 18:6a4db94011d3 55 friend class BaseDirHandle;
sahilmgandhi 18:6a4db94011d3 56
sahilmgandhi 18:6a4db94011d3 57 /** Opens a file from the filesystem
sahilmgandhi 18:6a4db94011d3 58 *
sahilmgandhi 18:6a4db94011d3 59 * @param filename The name of the file to open.
sahilmgandhi 18:6a4db94011d3 60 * @param flags One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
sahilmgandhi 18:6a4db94011d3 61 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
sahilmgandhi 18:6a4db94011d3 62 *
sahilmgandhi 18:6a4db94011d3 63 * @returns
sahilmgandhi 18:6a4db94011d3 64 * A pointer to a FileHandle object representing the
sahilmgandhi 18:6a4db94011d3 65 * file on success, or NULL on failure.
sahilmgandhi 18:6a4db94011d3 66 */
sahilmgandhi 18:6a4db94011d3 67 virtual FileHandle *open(const char *filename, int flags) = 0;
sahilmgandhi 18:6a4db94011d3 68
sahilmgandhi 18:6a4db94011d3 69 /** Remove a file from the filesystem.
sahilmgandhi 18:6a4db94011d3 70 *
sahilmgandhi 18:6a4db94011d3 71 * @param filename the name of the file to remove.
sahilmgandhi 18:6a4db94011d3 72 * @param returns 0 on success, -1 on failure.
sahilmgandhi 18:6a4db94011d3 73 */
sahilmgandhi 18:6a4db94011d3 74 virtual int remove(const char *filename) { (void) filename; return -1; };
sahilmgandhi 18:6a4db94011d3 75
sahilmgandhi 18:6a4db94011d3 76 /** Rename a file in the filesystem.
sahilmgandhi 18:6a4db94011d3 77 *
sahilmgandhi 18:6a4db94011d3 78 * @param oldname the name of the file to rename.
sahilmgandhi 18:6a4db94011d3 79 * @param newname the name to rename it to.
sahilmgandhi 18:6a4db94011d3 80 *
sahilmgandhi 18:6a4db94011d3 81 * @returns
sahilmgandhi 18:6a4db94011d3 82 * 0 on success,
sahilmgandhi 18:6a4db94011d3 83 * -1 on failure.
sahilmgandhi 18:6a4db94011d3 84 */
sahilmgandhi 18:6a4db94011d3 85 virtual int rename(const char *oldname, const char *newname) { (void) oldname, (void) newname; return -1; };
sahilmgandhi 18:6a4db94011d3 86
sahilmgandhi 18:6a4db94011d3 87 /** Opens a directory in the filesystem and returns a DirHandle
sahilmgandhi 18:6a4db94011d3 88 * representing the directory stream.
sahilmgandhi 18:6a4db94011d3 89 *
sahilmgandhi 18:6a4db94011d3 90 * @param name The name of the directory to open.
sahilmgandhi 18:6a4db94011d3 91 *
sahilmgandhi 18:6a4db94011d3 92 * @returns
sahilmgandhi 18:6a4db94011d3 93 * A DirHandle representing the directory stream, or
sahilmgandhi 18:6a4db94011d3 94 * NULL on failure.
sahilmgandhi 18:6a4db94011d3 95 */
sahilmgandhi 18:6a4db94011d3 96 virtual DirHandle *opendir(const char *name) { (void) name; return NULL; };
sahilmgandhi 18:6a4db94011d3 97
sahilmgandhi 18:6a4db94011d3 98 /** Creates a directory in the filesystem.
sahilmgandhi 18:6a4db94011d3 99 *
sahilmgandhi 18:6a4db94011d3 100 * @param name The name of the directory to create.
sahilmgandhi 18:6a4db94011d3 101 * @param mode The permissions to create the directory with.
sahilmgandhi 18:6a4db94011d3 102 *
sahilmgandhi 18:6a4db94011d3 103 * @returns
sahilmgandhi 18:6a4db94011d3 104 * 0 on success,
sahilmgandhi 18:6a4db94011d3 105 * -1 on failure.
sahilmgandhi 18:6a4db94011d3 106 */
sahilmgandhi 18:6a4db94011d3 107 virtual int mkdir(const char *name, mode_t mode) { (void) name, (void) mode; return -1; }
sahilmgandhi 18:6a4db94011d3 108
sahilmgandhi 18:6a4db94011d3 109 /** Store information about file in stat structure
sahilmgandhi 18:6a4db94011d3 110 *
sahilmgandhi 18:6a4db94011d3 111 * @param name The name of the file to find information about
sahilmgandhi 18:6a4db94011d3 112 * @param st The stat buffer to write to
sahilmgandhi 18:6a4db94011d3 113 * @returns
sahilmgandhi 18:6a4db94011d3 114 * 0 on success or un-needed,
sahilmgandhi 18:6a4db94011d3 115 * -1 on error
sahilmgandhi 18:6a4db94011d3 116 */
sahilmgandhi 18:6a4db94011d3 117 virtual int stat(const char *name, struct stat *st) { return -1; };
sahilmgandhi 18:6a4db94011d3 118 };
sahilmgandhi 18:6a4db94011d3 119
sahilmgandhi 18:6a4db94011d3 120 } // namespace mbed
sahilmgandhi 18:6a4db94011d3 121
sahilmgandhi 18:6a4db94011d3 122 #endif
sahilmgandhi 18:6a4db94011d3 123
sahilmgandhi 18:6a4db94011d3 124 /** @}*/