+/*
+ * Copy File
+*/
+FRESULT copy_file(const TCHAR* src, const TCHAR* dst)
+{
+ FIL fsrc, fdst;
+ FRESULT res;
+
+ /* File copy buffer */
+ uint8_t *buffer = (uint8_t *) malloc(CPY_BUF_SIZE);
+ if (buffer == NULL) {
+ res = (FRESULT) ENOMEM;
+ } else {
+
+ /* Open source file */
+ res = f_open(&fsrc, src, FA_READ);
+ if (res == FR_OK) {
+
+ /* Create destination file */
+ res = f_open(&fdst, dst, FA_WRITE | FA_CREATE_NEW);
+ if (res == FR_OK) {
+ UINT br, bw; /* File read/write count */
+
+ /* Copy source to destination */
+ for (;;) {
+ res = f_read(&fsrc, buffer, CPY_BUF_SIZE, &br); /* Read a chunk of source file */
+ if (res || br == 0)
+ break; /* error or eof */
+ res = f_write(&fdst, buffer, br, &bw); /* Write it to the destination file */
+ if (res != FR_OK)
+ break;
+ if (bw < br) {
+ res = (FRESULT) EFULL; /* disk full */
+ break;
+ }
+ }
+
+debug_cp("==== copy() res: %d, br: %d, bw: %d\n", res, br, bw);
+ f_close(&fdst);
+ if (res != FR_OK)
+ f_unlink(dst);
+ }
+ f_close(&fsrc);
+ }
+ free(buffer);
+ }
+
+ return res;
+}
+
+void ff_remove(const TCHAR *file, const TCHAR *dest UNUSED)