Robot Agent  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
file.h
Go to the documentation of this file.
1 
11 #ifndef __FILE_H
12 #define __FILE_H
13 
14 /* -- Includes -- */
15 
16 /* -- Enumurations -- */
17 
18 /* -- Types -- */
19 
23 typedef struct s_FILE_STRUCT
24 {
25  FILE *fd; // file descriptor
26  char name[256]; //name
27 
28 } file_t;
29 
30 /* -- Constants -- */
31 #define s_FILE_MODE_READ "r" // open for reading
32 #define s_FILE_MODE_WRITE "w" // open for writing (file need not exist)
33 #define s_FILE_MODE_APPEND "a" // open for appending (file need not exist)
34 #define s_FILE_MODE_RW_START "r+" // open for reading and writing, start at beginning
35 #define s_FILE_MODE_RW_OVER "w+" // open for reading and writing (overwrite file)
36 #define s_FILE_MODE_RW_APPEND "a+" // open for reading and writing (append if file exists)
37 
38 /* -- Function Prototypes -- */
39 file_t *file_open(const char *name, const char *mode); // Open file
40 file_t *file_open_time(const char *name, const char *ext, const char *mode); // Open file - name includes datetime
41 int file_close(file_t *fs); // Close file
42 int file_write(file_t *fs, char *data, int len); // Write to file
43 int file_write_direct(file_t *fs, char *data, int len); // Write and flush to file
44 int file_flush(file_t *fs); // Flush file
45 int file_readln(file_t *fs, char *buffer, size_t buflen); // Read line form file
46 
47 #endif /* __FILE_H */
int file_write(file_t *fs, char *data, int len)
Definition: file.c:101
FILE * fd
Definition: file.h:25
struct s_FILE_STRUCT file_t
File structure.
file_t * file_open_time(const char *name, const char *ext, const char *mode)
Definition: file.c:52
int file_readln(file_t *fs, char *buffer, size_t buflen)
Definition: file.c:145
file_t * file_open(const char *name, const char *mode)
Definition: file.c:31
int file_close(file_t *fs)
Definition: file.c:82
File structure.
Definition: file.h:23
char name[256]
Definition: file.h:26
int file_flush(file_t *fs)
Definition: file.c:132
int file_write_direct(file_t *fs, char *data, int len)
Definition: file.c:114