我想以递归方式检索给定路径中包含的所有文件,目录和子目录.但是当我的代码到达第二级(目录中的目录)时我遇到了问题:它不是打开内部目录来搜索其内容,而是抛出错误.这是我做的:
void getFile(char *path)
{
DIR *dir;
struct dirent *ent;
if ((dir = opendir(path)) != NULL) {
/* print all the files and directories within directory */
while ((ent = readdir(dir)) != NULL) {
if((strcmp(ent->d_name,"..") != 0) && (strcmp(ent->d_name,".") != 0)){
printf ("%s", ent->d_name);
if(ent->d_type == DT_DIR){
printf("/\n");
getFile(ent->d_name);
}
else{
printf("\n");
}
} // end of if condition
} // end of while loop
closedir (dir);
}
Run Code Online (Sandbox Code Playgroud) 我试图在slideUp之后清空一个div,但它在完全向上滑动之前变空了.这是我的代码.我需要清除的数据正在通过Ajax获取.这是完整的代码
$('.more').click(function(e){
e.preventDefault();
var fd = $(this).attr('id');
var data = 'fd='+ fd ;
if($('#e_' + fd).is(':visible')){
$('#e_' + fd).slideUp(300, function() {
$('#e_' + fd).empty();
});
}
else{
$('#e_' + fd).empty().append('<div class="load"></div>').slideDown(300); // for ajax loader
$.ajax({
type: "POST",
url: "file.php",
data: data,
cache: false,
success: function(html)
{
$('#e_' + fd).empty().append(html).slideDown(800);
}
});
return false; }
});
Run Code Online (Sandbox Code Playgroud)
使用ajax加载程序会出现同样的问题.事实上它也没有加载.