- fr = f_opendir(&dir, path);\r
- if (fr == FR_OK) {\r
- for (i = 0; path[i]; i++) ;\r
- path[i++] = '/';\r
- for (;;) {\r
- fr = f_readdir(&dir, &fno);\r
- if (fr != FR_OK || !fno.fname[0]) break;\r
- if (_FS_RPATH && fno.fname[0] == '.') continue;\r
- j = 0;\r
- do\r
- path[i+j] = fno.fname[j];\r
- while (fno.fname[j++]);\r
- if (fno.fattrib & AM_DIR) {\r
- fr = empty_directory(path);\r
- if (fr != FR_OK) break;\r
+\r
+ fr = f_opendir(&dir, path); /* Open the sub-directory to make it empty */\r
+ if (fr != FR_OK) return fr;\r
+\r
+ for (i = 0; path[i]; i++) ; /* Get current path length */\r
+ path[i++] = _T('/');\r
+\r
+ for (;;) {\r
+ fr = f_readdir(&dir, fno); /* Get a directory item */\r
+ if (fr != FR_OK || !fno->fname[0]) break; /* End of directory? */\r
+ j = 0;\r
+ do { /* Make a path name */\r
+ if (i + j >= sz_buff) { /* Buffer over flow? */\r
+ fr = 100; break; /* Fails with 100 when buffer overflow */\r