From d3745ff4aa0e4d04fae7344c5e23407db2406eee Mon Sep 17 00:00:00 2001 From: payton Date: Fri, 17 Nov 2023 11:14:36 +0800 Subject: [PATCH] =?UTF-8?q?1.SD=E5=8D=A1=E5=88=A0=E9=99=A4=E7=A9=BA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sf_app/code/source/storeMng/sf_storeMng.c | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c b/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c index d14b4183e..53f9108bd 100644 --- a/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c +++ b/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c @@ -669,6 +669,34 @@ static void trave_file(char* path) return; } +int sf_is_directory_empty(const char *path) +{ + DIR *dir = opendir(path); + + if (dir == NULL) { + MLOGE("Error opening directory"); + return -1; + } + + struct dirent *entry; + int count = 0; + + while ((entry = readdir(dir)) != NULL) { + + if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { + count++; + break; + } + } + + closedir(dir); + + if (count == 0) { + return 1; + } else { + return 0; + } +} int sf_dcf_resort_min(void) { @@ -706,6 +734,13 @@ int sf_dcf_resort_min(void) MLOGD("DirKey:%d,FileKey:%d\n", gLastDirKey, gLastFileKey); if(gLastFileKey <= MAX_DCF_FILE_NUM) { + sprintf(sTmp,"%s/%d%s",sRootPath,gLastDirKey,DCF_DIR_NAME); + if(sf_is_directory_empty(sTmp)) + { + MLOGD("Will Delete Dir:%s\n", sTmp); + remove(sTmp); + system("sync"); + } gLastDirKey = i; MLOGD("DirKey:%d,FileKey:%d\n", gLastDirKey, gLastFileKey); return 0;