标签:android ndk 文件遍历 文件删除
// 删除指定文件夹内所有文件 JNIEXPORT void JNICALL Java_com_test_util_T_deleteFiles(JNIEnv *env, jclass obj, jstring fileFolder) { const char *file_folder = (*env)->GetStringUTFChars(env, fileFolder, 0); DIR *pDir = NULL; struct dirent *dmsg; char szFileName[128]; char szFolderName[128]; strcpy(szFolderName, file_folder); strcat(szFolderName, "/%s"); if ((pDir = opendir(file_folder)) != NULL) { // 遍历目录并删除文件 while ((dmsg = readdir(pDir)) != NULL) { if (strcmp(dmsg->d_name, ".") != 0 && strcmp(dmsg->d_name, "..") != 0) { sprintf(szFileName, szFolderName, dmsg->d_name); remove(szFileName); } } } if (pDir != NULL) { closedir(pDir); } (*env)->ReleaseStringUTFChars(env, fileFolder, file_folder); }
long hFile = 0; struct _finddata_t file_info; hFile = _findfirst("test\\*", &file_info); while (_findnext(hFile, & file_info) == 0) { if (strcmp(file_info. name, ".") != 0 && strcmp(file_info. name, "..") != 0) { printf("%s\n", file_info.name); } else { printf("%s\n", "invalid"); } } _findclose( hFile);
android ndk下文件遍历与删除,布布扣,bubuko.com
标签:android ndk 文件遍历 文件删除
原文地址:http://blog.csdn.net/grafx/article/details/37737853