diff options
author | Leo C | 2014-12-16 16:03:06 +0100 |
---|---|---|
committer | Leo C | 2014-12-16 16:03:06 +0100 |
commit | 35edb766593d019b89a3f40b6d6cdd2b50f18032 (patch) | |
tree | d46f856c2f2b5f27b479162b234ff8bafcd8c349 /avr/cmd_fat.c | |
parent | 15e476bc8dcadb88cad1e593e22cbeca62d05edb (diff) | |
download | z180-stamp-35edb766593d019b89a3f40b6d6cdd2b50f18032.zip |
Add copyright notice
Diffstat (limited to 'avr/cmd_fat.c')
-rw-r--r-- | avr/cmd_fat.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/avr/cmd_fat.c b/avr/cmd_fat.c index df2ae69..8ed7ae3 100644 --- a/avr/cmd_fat.c +++ b/avr/cmd_fat.c @@ -1,3 +1,13 @@ +/* + * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +/* + * FAT filesystem commands + */ + #include "common.h" #include <stdlib.h> #include <string.h> @@ -290,6 +300,39 @@ command_ret_t do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[ return CMD_RET_SUCCESS; } +static +FRESULT mkpath(TCHAR *path) +{ + /* TODO: */ + (void) path; +#if 0 + FILINFO fd + TCHAR *p, *q; + FRESULT ret; + +#if _USE_LFN + fd.lfname = 0; +#endif + + + res = f_stat (path, &fd) + + p = strchr(path, ':'); + if (p == NULL || *++p == '\0' || *p++ != '/') + return FR_OK; + + while ((q = strchr(p, '/')) != NULL) { + *q = '\0'; + ret = f_mkdir(path); + *q = '/'; + if (ret != FR_OK && ret != FR_EXIST) + return ret; + p = q + 1; + } +#endif + + return FR_OK; +} /* * fatread/write - load binary file to/from a dos filesystem @@ -343,6 +386,12 @@ command_ret_t do_fat_rw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[ } res = f_mount(FatFs, argv[1], 0); + + if (!res) { + if (dowrite) { + res = mkpath(argv[1]); + } + } if (!res) { res = f_open(&File, argv[1], dowrite ? FA_WRITE | FA_CREATE_ALWAYS : FA_READ ); |