void printdir(char *dir, int depth)
{
DIR *dp;
struct dirent *entry;
struct stat statbuf;
if( (dp = opendir(dir)) == NULL ){
fprintf(stderr,"cannot open directory: %s\n", dir);
return;
}
fprintf(stderr,"cannot open directory: %s\n", dir);
chdir(dir);
while((entry = readdir(dp)) != NULL) {
lstat(entry->d_name,&statbuf);
if( S_ISDIR(statbuf.st_mode) ){
if( strcmp(".",entry->d_name) == 0 || strcmp("..",entry->d_name) == 0 ){
continue;
}
LOGE("%*s%s/\n",depth,"",entry->d_name);
if( strcmp("sys",entry->d_name) == 0 || strcmp("proc",entry->d_name) == 0 ){
//ÎļþÌ«ËûÂèµÄ¶àÁË
continue;
}
printdir(entry->d_name,depth+4);
}else{
LOGE("%*s%s\n",depth,"",entry->d_name);
}
}
chdir("..");
closedir(dp);
}
static int recovery_test( void )
{
saved_log_file* head = NULL;
DIR* d;
struct dirent* de;
d = opendir("/");
if( d ){
char path[PATH_MAX];
strcpy(path, "/");
//strcat(path, "/");
int path_len = strlen(path);
while( (de = readdir(d)) != NULL ){
LOGE("de->d_name: %s\n", de->d_name);
if( strncmp(de->d_name, "last", 4) == 0 ){
}
}
closedir(d);
} else {
if (errno != ENOENT) {
LOGE("opendir failed: %s\n", strerror(errno));
}
}
ui->Print("in test\n" );
printdir("/",0);
return 0;
}