get rid of '..' and '.' from result of directory.

This commit is contained in:
SANO Masatoshi 2017-11-11 12:44:10 +09:00
parent def9aea3c0
commit 4753f95973

View file

@ -66,10 +66,13 @@ LVal directory(char* path) {
if(dir==NULL)
return 0;
while((dirent=readdir(dir))!=0) {
char* str=q(dirent->d_name);
if(dirent->d_type & DT_DIR)
str=s_cat2(str,q("/"));
ret=conss(str,ret);
if(!(strcmp(dirent->d_name,".")==0 ||
strcmp(dirent->d_name,"..")==0)) {
char* str=q(dirent->d_name);
if(dirent->d_type & DT_DIR)
str=s_cat2(str,q("/"));
ret=conss(str,ret);
}
}
closedir(dir);
return ret;