Choco OS  V.0.16.9.0
Join to the chocolate world
oc_fs.h
Go to the documentation of this file.
1 
28 #ifndef INC_FS_OC_FS_H_
29 #define INC_FS_OC_FS_H_
30 
31 #include <stdint.h>
32 #include <stdbool.h>
33 #include <oc_list.h>
34 #include <oc_ioctl.h>
35 #include <oc_time.h>
36 #include <oc_errors.h>
37 
43 #define _________________________________________TYPES_SECTION______________________________________________________________________________
44 
47 typedef struct File_t * oC_File_t;
48 
49 //==========================================================================================================================================
53 //==========================================================================================================================================
54 typedef enum
55 {
59  oC_FileSystem_ModeFlags__FailIfExists = (1<<2),
60  oC_FileSystem_ModeFlags__FailIfNotExists= (1<<3),
61  oC_FileSystem_ModeFlags__Open = (1<<4),
62  oC_FileSystem_ModeFlags__Create = (1<<5),
63  oC_FileSystem_ModeFlags_OpenExisting = oC_FileSystem_ModeFlags__Open |
64  oC_FileSystem_ModeFlags__FailIfNotExists ,
65  oC_FileSystem_ModeFlags_OpenAlways = oC_FileSystem_ModeFlags__Open |
66  oC_FileSystem_ModeFlags__Create ,
67  oC_FileSystem_ModeFlags_CreateNew = oC_FileSystem_ModeFlags__Create |
68  oC_FileSystem_ModeFlags__FailIfExists,
69  oC_FileSystem_ModeFlags_CreateNewAlways = oC_FileSystem_ModeFlags__Create
71 
72 typedef enum
73 {
74  oC_FileSystem_FileAttributes_ReadOnly = (1<<0),
75  oC_FileSystem_FileAttributes_Archive = (1<<1),
76  oC_FileSystem_FileAttributes_System = (1<<2),
77  oC_FileSystem_FileAttributes_Hidden = (1<<3)
78 } oC_FileSystem_FileAttributes_t;
79 
80 typedef enum
81 {
82  oC_FileSystem_FileType_File ,
83  oC_FileSystem_FileType_Directory
84 } oC_FileSystem_FileType_t;
85 
86 typedef struct Dir_t * oC_Dir_t;
87 
88 typedef struct
89 {
90  oC_Timestamp_t Timestamp;
91  const char * Name;
92  uint32_t Size;
93  oC_FileSystem_FileType_t FileType;
95 
96 typedef struct Context_t * oC_FileSystem_Context_t;
97 
98 typedef oC_ErrorCode_t (*oC_FileSystem_init_t) ( oC_FileSystem_Context_t * outContext );
99 typedef oC_ErrorCode_t (*oC_FileSystem_deinit_t) ( oC_FileSystem_Context_t Context );
100 typedef oC_ErrorCode_t (*oC_FileSystem_fopen_t) ( oC_FileSystem_Context_t Context , oC_File_t * outFile , const char * Path , oC_FileSystem_ModeFlags_t Mode , oC_FileSystem_FileAttributes_t Attributes );
101 typedef oC_ErrorCode_t (*oC_FileSystem_fclose_t) ( oC_FileSystem_Context_t Context , oC_File_t File );
102 typedef oC_ErrorCode_t (*oC_FileSystem_fread_t) ( oC_FileSystem_Context_t Context , oC_File_t File , void * outBuffer , uint32_t * Size );
103 typedef oC_ErrorCode_t (*oC_FileSystem_fwrite_t) ( oC_FileSystem_Context_t Context , oC_File_t File , const void * Buffer , uint32_t * Size );
104 typedef oC_ErrorCode_t (*oC_FileSystem_lseek_t) ( oC_FileSystem_Context_t Context , oC_File_t File , uint32_t Offset );
105 typedef oC_ErrorCode_t (*oC_FileSystem_ioctl_t) ( oC_FileSystem_Context_t Context , oC_File_t File , oC_Ioctl_Command_t Command , void * Pointer);
106 typedef oC_ErrorCode_t (*oC_FileSystem_sync_t) ( oC_FileSystem_Context_t Context , oC_File_t File );
107 typedef oC_ErrorCode_t (*oC_FileSystem_getc_t) ( oC_FileSystem_Context_t Context , char * outCharacter , oC_File_t File );
108 typedef oC_ErrorCode_t (*oC_FileSystem_putc_t) ( oC_FileSystem_Context_t Context , char Character , oC_File_t File );
109 typedef int32_t (*oC_FileSystem_tell_t) ( oC_FileSystem_Context_t Context , oC_File_t File );
110 typedef bool (*oC_FileSystem_eof_t) ( oC_FileSystem_Context_t Context , oC_File_t File );
111 typedef uint32_t (*oC_FileSystem_size_t) ( oC_FileSystem_Context_t Context , oC_File_t File );
112 
113 
114 typedef oC_ErrorCode_t (*oC_FileSystem_opendir_t) ( oC_FileSystem_Context_t Context , oC_Dir_t * outDir , const char * Path );
115 typedef oC_ErrorCode_t (*oC_FileSystem_closedir_t) ( oC_FileSystem_Context_t Context , oC_Dir_t Dir );
116 typedef oC_ErrorCode_t (*oC_FileSystem_readdir_t) ( oC_FileSystem_Context_t Context , oC_Dir_t Dir , oC_FileInfo_t * outFileInfo );
117 
118 typedef oC_ErrorCode_t (*oC_FileSystem_stat_t) ( oC_FileSystem_Context_t Context , const char * Path , oC_FileInfo_t * outFileInfo);
119 typedef oC_ErrorCode_t (*oC_FileSystem_unlink_t) ( oC_FileSystem_Context_t Context , const char * Path);
120 typedef oC_ErrorCode_t (*oC_FileSystem_rename_t) ( oC_FileSystem_Context_t Context , const char * OldName , const char * NewName);
121 typedef oC_ErrorCode_t (*oC_FileSystem_chmod_t) ( oC_FileSystem_Context_t Context , const char * Path, oC_FileSystem_FileAttributes_t Attributes , oC_FileSystem_FileAttributes_t Mask);
122 typedef oC_ErrorCode_t (*oC_FileSystem_utime_t) ( oC_FileSystem_Context_t Context , const char * Path , oC_Timestamp_t Timestamp );
123 typedef oC_ErrorCode_t (*oC_FileSystem_mkdir_t) ( oC_FileSystem_Context_t Context , const char * Path);
124 typedef bool (*oC_FileSystem_DirExists_t)( oC_FileSystem_Context_t Context , const char * Path);
125 
126 typedef struct
127 {
128  const char * Name;
129  oC_FileSystem_init_t init;
130  oC_FileSystem_deinit_t deinit;
131  oC_FileSystem_fopen_t fopen;
132  oC_FileSystem_fclose_t fclose;
133  oC_FileSystem_fread_t fread;
134  oC_FileSystem_fwrite_t fwrite;
135  oC_FileSystem_lseek_t lseek;
136  oC_FileSystem_ioctl_t ioctl;
137  oC_FileSystem_sync_t sync;
138  oC_FileSystem_getc_t Getc;
139  oC_FileSystem_putc_t Putc;
140  oC_FileSystem_tell_t tell;
141  oC_FileSystem_eof_t eof;
142  oC_FileSystem_size_t size;
143 
144  oC_FileSystem_opendir_t opendir;
145  oC_FileSystem_closedir_t closedir;
146  oC_FileSystem_readdir_t readdir;
147 
148  oC_FileSystem_stat_t stat;
149  oC_FileSystem_unlink_t unlink;
150  oC_FileSystem_rename_t rename;
151  oC_FileSystem_chmod_t chmod;
152  oC_FileSystem_utime_t utime;
153  oC_FileSystem_mkdir_t mkdir;
154  oC_FileSystem_DirExists_t DirExists;
156 
158 
159 #undef _________________________________________TYPES_SECTION______________________________________________________________________________
160 
162 #endif /* INC_FS_OC_FS_H_ */
open file (create new if it does not exist)
Definition: oc_fs.h:65
specifies read access to the file
Definition: oc_fs.h:56
create new file (fails if file exists)
Definition: oc_fs.h:67
The library with time definitions.
The file with list library.
oC_FileSystem_ModeFlags_t
Definition: oc_fs.h:54
create new file (overwrite if exists)
Definition: oc_fs.h:69
The file with interface for IOCTL.
specifies write access to the file
Definition: oc_fs.h:57
stores ETH context
Definition: oc_eth.c:97
open file (fails if file does not exist)
Definition: oc_fs.h:63
moves offset pointer to the end of the file
Definition: oc_fs.h:58
Definition: oc_devfs.c:60