Webserver+3d print

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers fs_port.h Source File

fs_port.h

Go to the documentation of this file.
00001 /**
00002  * @file fs_port.h
00003  * @brief File system abstraction layer
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License
00011  * as published by the Free Software Foundation; either version 2
00012  * of the License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00022  *
00023  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00024  * @version 1.7.6
00025  **/
00026 
00027 #ifndef _FS_PORT_H
00028 #define _FS_PORT_H
00029 
00030 //Dependencies
00031 #include "fs_port_config.h"
00032 #include "os_port.h"
00033 #include "date_time.h"
00034 #include "error.h"
00035 
00036 //Number of files that can be opened simultaneously
00037 #ifndef FS_MAX_FILES
00038    #define FS_MAX_FILES 8
00039 #elif (FS_MAX_FILES < 1)
00040    #error FS_MAX_FILES parameter is not valid
00041 #endif
00042 
00043 //Number of directories that can be opened simultaneously
00044 #ifndef FS_MAX_DIRS
00045    #define FS_MAX_DIRS 8
00046 #elif (FS_MAX_DIRS < 1)
00047    #error FS_MAX_DIRS parameter is not valid
00048 #endif
00049 
00050 //Maximum filename length
00051 #ifndef FS_MAX_NAME_LEN
00052    #define FS_MAX_NAME_LEN 127
00053 #elif (FS_MAX_NAME_LEN < 11)
00054    #error FS_MAX_NAME_LEN parameter is not valid
00055 #endif
00056 
00057 
00058 /**
00059  * @brief File attributes
00060  **/
00061 
00062 typedef enum
00063 {
00064    FS_FILE_ATTR_READ_ONLY   = 0x01,
00065    FS_FILE_ATTR_HIDDEN      = 0x02,
00066    FS_FILE_ATTR_SYSTEM      = 0x04,
00067    FS_FILE_ATTR_VOLUME_NAME = 0x08,
00068    FS_FILE_ATTR_DIRECTORY   = 0x10,
00069    FS_FILE_ATTR_ARCHIVE     = 0x20
00070 } FsFileAttributes;
00071 
00072 
00073 /**
00074  * @brief File access mode
00075  **/
00076 
00077 typedef enum
00078 {
00079    FS_FILE_MODE_READ   = 1,
00080    FS_FILE_MODE_WRITE  = 2,
00081    FS_FILE_MODE_CREATE = 4,
00082    FS_FILE_MODE_TRUNC  = 8
00083 } FsFileMode;
00084 
00085 
00086 /**
00087  * @brief File seek origin
00088  **/
00089 
00090 typedef enum
00091 {
00092    FS_SEEK_SET = 0,
00093    FS_SEEK_CUR = 1,
00094    FS_SEEK_END = 2
00095 } FsSeekOrigin;
00096 
00097 
00098 /**
00099  * @brief Directory entry
00100  **/
00101 
00102 typedef struct
00103 {
00104    uint32_t attributes;
00105    uint32_t size;
00106    DateTime modified;
00107    char_t name[FS_MAX_NAME_LEN + 1];
00108 } FsDirEntry;
00109 
00110 
00111 /**
00112  * @brief File handle
00113  **/
00114 
00115 typedef void FsFile;
00116 
00117 
00118 /**
00119  * @brief Directory handle
00120  **/
00121 
00122 typedef void FsDir;
00123 
00124 
00125 //File system abstraction layer
00126 error_t fsInit(void);
00127 
00128 bool_t fsFileExists(const char_t *path);
00129 error_t fsGetFileSize(const char_t *path, uint32_t *size);
00130 error_t fsRenameFile(const char_t *oldPath, const char_t *newPath);
00131 error_t fsDeleteFile(const char_t *path);
00132 
00133 FsFile *fsOpenFile(const char_t *path, uint_t mode);
00134 error_t fsSeekFile(FsFile *file, int_t offset, uint_t origin);
00135 error_t fsWriteFile(FsFile *file, void *data, size_t length);
00136 error_t fsReadFile(FsFile *file, void *data, size_t size, size_t *length);
00137 void fsCloseFile(FsFile *file);
00138 
00139 bool_t fsDirExists(const char_t *path);
00140 error_t fsCreateDir(const char_t *path);
00141 error_t fsRemoveDir(const char_t *path);
00142 
00143 FsDir *fsOpenDir(const char_t *path);
00144 error_t fsReadDir(FsDir *dir, FsDirEntry *dirEntry);
00145 void fsCloseDir(FsDir *dir);
00146 
00147 #endif
00148