Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FileSystemHandle.h Source File

FileSystemHandle.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef MBED_FILESYSTEMHANDLE_H
00017 #define MBED_FILESYSTEMHANDLE_H
00018 
00019 #include "platform/platform.h"
00020 
00021 #include "platform/FileBase.h"
00022 #include "platform/FileHandle.h"
00023 #include "platform/DirHandle.h"
00024 #include "platform/NonCopyable.h"
00025 
00026 namespace mbed {
00027 /** \addtogroup platform */
00028 /** @{*/
00029 /**
00030  * \defgroup platform_FileSystemHandle FileSystemHandle functions
00031  * @{
00032  */
00033 
00034 
00035 /** A filesystem-like object is one that can be used to open file-like
00036  *  objects though it by fopen("/name/filename", mode)
00037  *
00038  *  Implementations must define at least open (the default definitions
00039  *  of the rest of the functions just return error values).
00040  *
00041  * @note Synchronization level: Set by subclass
00042  */
00043 class FileSystemHandle : private NonCopyable<FileSystemHandle> {
00044 public:
00045     /** FileSystemHandle lifetime
00046      */
00047     virtual ~FileSystemHandle() {}
00048 
00049     /** Open a file on the filesystem
00050      *
00051      *  @param file     Destination for the handle to a newly created file
00052      *  @param filename The name of the file to open
00053      *  @param flags    The flags to open the file in, one of O_RDONLY, O_WRONLY, O_RDWR,
00054      *                  bitwise or'd with one of O_CREAT, O_TRUNC, O_APPEND
00055      *  @return         0 on success, negative error code on failure
00056      */
00057     virtual int open(FileHandle **file, const char *filename, int flags) = 0;
00058 
00059     /** Open a directory on the filesystem
00060      *
00061      *  @param dir      Destination for the handle to the directory
00062      *  @param path     Name of the directory to open
00063      *  @return         0 on success, negative error code on failure
00064      */
00065     virtual int open(DirHandle **dir, const char *path);
00066 
00067     /** Remove a file from the filesystem.
00068      *
00069      *  @param path     The name of the file to remove.
00070      *  @return         0 on success, negative error code on failure
00071      */
00072     virtual int remove(const char *path);
00073 
00074     /** Rename a file in the filesystem.
00075      *
00076      *  @param path     The name of the file to rename.
00077      *  @param newpath  The name to rename it to
00078      *  @return         0 on success, negative error code on failure
00079      */
00080     virtual int rename(const char *path, const char *newpath);
00081 
00082     /** Store information about the file in a stat structure
00083      *
00084      *  @param path     The name of the file to find information about
00085      *  @param st       The stat buffer to write to
00086      *  @return         0 on success, negative error code on failure
00087      */
00088     virtual int stat(const char *path, struct stat *st);
00089 
00090     /** Create a directory in the filesystem.
00091      *
00092      *  @param path     The name of the directory to create.
00093      *  @param mode     The permissions with which to create the directory
00094      *  @return         0 on success, negative error code on failure
00095      */
00096     virtual int mkdir(const char *path, mode_t mode);
00097 };
00098 /**@}*/
00099 
00100 /**@}*/
00101 
00102 } // namespace mbed
00103 
00104 #endif
00105 
00106 /** @}*/