This is a data logger program to be implemented with an instrument amplifier.

Dependencies:   mbed

Committer:
KISScientific
Date:
Tue Apr 04 18:01:11 2017 +0000
Revision:
0:d75ca4e39672
This is a data logger program.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
KISScientific 0:d75ca4e39672 1 /* mbed Microcontroller Library - FileSystemLike
KISScientific 0:d75ca4e39672 2 * Copyright (c) 2008-2009 ARM Limited. All rights reserved.
KISScientific 0:d75ca4e39672 3 * sford
KISScientific 0:d75ca4e39672 4 */
KISScientific 0:d75ca4e39672 5
KISScientific 0:d75ca4e39672 6 #ifndef MBED_FILESYSTEMLIKE_H
KISScientific 0:d75ca4e39672 7 #define MBED_FILESYSTEMLIKE_H
KISScientific 0:d75ca4e39672 8
KISScientific 0:d75ca4e39672 9 #ifdef __ARMCC_VERSION
KISScientific 0:d75ca4e39672 10 # define O_RDONLY 0
KISScientific 0:d75ca4e39672 11 # define O_WRONLY 1
KISScientific 0:d75ca4e39672 12 # define O_RDWR 2
KISScientific 0:d75ca4e39672 13 # define O_CREAT 0x0200
KISScientific 0:d75ca4e39672 14 # define O_TRUNC 0x0400
KISScientific 0:d75ca4e39672 15 # define O_APPEND 0x0008
KISScientific 0:d75ca4e39672 16 typedef int mode_t;
KISScientific 0:d75ca4e39672 17 #else
KISScientific 0:d75ca4e39672 18 # include <sys/fcntl.h>
KISScientific 0:d75ca4e39672 19 #endif
KISScientific 0:d75ca4e39672 20 #include "Base.h"
KISScientific 0:d75ca4e39672 21 #include "FileHandle.h"
KISScientific 0:d75ca4e39672 22 #include "DirHandle.h"
KISScientific 0:d75ca4e39672 23
KISScientific 0:d75ca4e39672 24 namespace mbed {
KISScientific 0:d75ca4e39672 25
KISScientific 0:d75ca4e39672 26 /* Class FileSystemLike
KISScientific 0:d75ca4e39672 27 * A filesystem-like object is one that can be used to open files
KISScientific 0:d75ca4e39672 28 * though it by fopen("/name/filename", mode)
KISScientific 0:d75ca4e39672 29 *
KISScientific 0:d75ca4e39672 30 * Implementations must define at least open (the default definitions
KISScientific 0:d75ca4e39672 31 * of the rest of the functions just return error values).
KISScientific 0:d75ca4e39672 32 */
KISScientific 0:d75ca4e39672 33 class FileSystemLike : public Base {
KISScientific 0:d75ca4e39672 34
KISScientific 0:d75ca4e39672 35 public:
KISScientific 0:d75ca4e39672 36
KISScientific 0:d75ca4e39672 37 /* Constructor FileSystemLike
KISScientific 0:d75ca4e39672 38 *
KISScientific 0:d75ca4e39672 39 * Variables
KISScientific 0:d75ca4e39672 40 * name - The name to use for the filesystem.
KISScientific 0:d75ca4e39672 41 */
KISScientific 0:d75ca4e39672 42 FileSystemLike(const char *name) : Base(name) {}
KISScientific 0:d75ca4e39672 43
KISScientific 0:d75ca4e39672 44 /* Function open
KISScientific 0:d75ca4e39672 45 *
KISScientific 0:d75ca4e39672 46 * Variables
KISScientific 0:d75ca4e39672 47 * filename - The name of the file to open.
KISScientific 0:d75ca4e39672 48 * flags - One of O_RDONLY, O_WRONLY, or O_RDWR, OR'd with
KISScientific 0:d75ca4e39672 49 * zero or more of O_CREAT, O_TRUNC, or O_APPEND.
KISScientific 0:d75ca4e39672 50 * returns - A pointer to a FileHandle object representing the
KISScientific 0:d75ca4e39672 51 * file on success, or NULL on failure.
KISScientific 0:d75ca4e39672 52 */
KISScientific 0:d75ca4e39672 53 virtual FileHandle *open(const char *filename, int flags) = 0;
KISScientific 0:d75ca4e39672 54
KISScientific 0:d75ca4e39672 55 /* Function remove
KISScientific 0:d75ca4e39672 56 * Remove a file from the filesystem.
KISScientific 0:d75ca4e39672 57 *
KISScientific 0:d75ca4e39672 58 * Variables
KISScientific 0:d75ca4e39672 59 * filename - the name of the file to remove.
KISScientific 0:d75ca4e39672 60 * returns - 0 on success, -1 on failure.
KISScientific 0:d75ca4e39672 61 */
KISScientific 0:d75ca4e39672 62 virtual int remove(const char *filename) { return -1; };
KISScientific 0:d75ca4e39672 63
KISScientific 0:d75ca4e39672 64 /* Function rename
KISScientific 0:d75ca4e39672 65 * Rename a file in the filesystem.
KISScientific 0:d75ca4e39672 66 *
KISScientific 0:d75ca4e39672 67 * Variables
KISScientific 0:d75ca4e39672 68 * oldname - the name of the file to rename.
KISScientific 0:d75ca4e39672 69 * newname - the name to rename it to.
KISScientific 0:d75ca4e39672 70 * returns - 0 on success, -1 on failure.
KISScientific 0:d75ca4e39672 71 */
KISScientific 0:d75ca4e39672 72 virtual int rename(const char *oldname, const char *newname) { return -1; };
KISScientific 0:d75ca4e39672 73
KISScientific 0:d75ca4e39672 74 /* Function opendir
KISScientific 0:d75ca4e39672 75 * Opens a directory in the filesystem and returns a DirHandle
KISScientific 0:d75ca4e39672 76 * representing the directory stream.
KISScientific 0:d75ca4e39672 77 *
KISScientific 0:d75ca4e39672 78 * Variables
KISScientific 0:d75ca4e39672 79 * name - The name of the directory to open.
KISScientific 0:d75ca4e39672 80 * returns - A DirHandle representing the directory stream, or
KISScientific 0:d75ca4e39672 81 * NULL on failure.
KISScientific 0:d75ca4e39672 82 */
KISScientific 0:d75ca4e39672 83 virtual DirHandle *opendir(const char *name) { return NULL; };
KISScientific 0:d75ca4e39672 84
KISScientific 0:d75ca4e39672 85 /* Function mkdir
KISScientific 0:d75ca4e39672 86 * Creates a directory in the filesystem.
KISScientific 0:d75ca4e39672 87 *
KISScientific 0:d75ca4e39672 88 * Variables
KISScientific 0:d75ca4e39672 89 * name - The name of the directory to create.
KISScientific 0:d75ca4e39672 90 * mode - The permissions to create the directory with.
KISScientific 0:d75ca4e39672 91 * returns - 0 on success, -1 on failure.
KISScientific 0:d75ca4e39672 92 */
KISScientific 0:d75ca4e39672 93 virtual int mkdir(const char *name, mode_t mode) { return -1; }
KISScientific 0:d75ca4e39672 94
KISScientific 0:d75ca4e39672 95 // TODO other filesystem functions (mkdir, rm, rn, ls etc)
KISScientific 0:d75ca4e39672 96
KISScientific 0:d75ca4e39672 97 };
KISScientific 0:d75ca4e39672 98
KISScientific 0:d75ca4e39672 99 } // namespace mbed
KISScientific 0:d75ca4e39672 100
KISScientific 0:d75ca4e39672 101 #endif