diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-08-13 15:48:16 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-08-13 15:48:16 +1000 |
commit | efa13a879df590ce0043a5b4f97597484bf264e1 (patch) | |
tree | dcded7e06aa5467496d4f9aa365e00fb096a6801 /3rdparty/fatfs-0.10b/doc/img/app1.c | |
parent | 10902154aec652a3fcdf028b2c6ff16743464973 (diff) | |
download | uGFX-efa13a879df590ce0043a5b4f97597484bf264e1.tar.gz uGFX-efa13a879df590ce0043a5b4f97597484bf264e1.tar.bz2 uGFX-efa13a879df590ce0043a5b4f97597484bf264e1.zip |
Move 3rd Party source to a new directory.
Rationalise Fatfs code and fix a couple of configuration issues.
Diffstat (limited to '3rdparty/fatfs-0.10b/doc/img/app1.c')
-rw-r--r-- | 3rdparty/fatfs-0.10b/doc/img/app1.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/3rdparty/fatfs-0.10b/doc/img/app1.c b/3rdparty/fatfs-0.10b/doc/img/app1.c new file mode 100644 index 00000000..b3ff7fd7 --- /dev/null +++ b/3rdparty/fatfs-0.10b/doc/img/app1.c @@ -0,0 +1,43 @@ +/*------------------------------------------------------------/ +/ Open or create a file in append mode +/------------------------------------------------------------*/ + +FRESULT open_append ( + FIL* fp, /* [OUT] File object to create */ + const char* path /* [IN] File name to be opened */ +) +{ + FRESULT fr; + + /* Opens an existing file. If not exist, creates a new file. */ + fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS); + if (fr == FR_OK) { + /* Seek to end of the file to append data */ + fr = f_lseek(fp, f_size(fp)); + if (fr != FR_OK) + f_close(fp); + } + return fr; +} + + +int main (void) +{ + FRESULT fr; + FATFS fs; + FIL fil; + + /* Open or create a log file and ready to append */ + f_mount(&fs, "", 0); + fr = open_append(&fil, "logfile.txt"); + if (fr != FR_OK) return 1; + + /* Append a line */ + f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min); + + /* Close the file */ + f_close(&fil); + + return 0; +} + |