+/*
+ * (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>
#include "timer.h"
#include "debug.h"
-
-#define MAX_MEMORY (1ul << 20)
+/* TODO: use memory size test function (cmd_mem.c) */
+#define MAX_MEMORY (1ul << 19)
#define BUFFER_SIZE 512
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
}
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 );