int appledouble_readdir(struct afp_volume * volume, const char *path, struct afp_file_info **base) { unsigned int resource; char * newpath; resource = extra_translate(volume, path, &newpath); switch(resource) { case 0: return 0; case AFP_META_APPLEDOUBLE: { struct afp_file_info *fp, *prev=NULL, *newfp=NULL, *newchain=NULL, *last=NULL; ll_readdir(volume, newpath,base,1); /* Add .finderinfo files */ for (fp=*base;fp;fp=fp->next) { add_fp(&newchain,fp,finderinfo_string,32); /* Add comments if it has a size > 0 */ if (ensure_dt_opened(volume)==0) { int size=get_comment_size(volume, fp->basic.name,fp->did); if (size>0) add_fp(&newchain,fp,comment_string,32); } if (fp->basic.unixprivs.permissions & S_IFREG) { if (fp->resourcesize==0) { remove_fp(base,fp); } } else { remove_fp(base,fp); } last=fp; } if ((newchain) && (last)) { last->next=newchain; } free(newpath); return 1; case AFP_META_RESOURCE: case AFP_META_SERVER_ICON: case AFP_META_COMMENT: free(newpath); return -ENOTDIR; } } return 0; }
int ml_readdir(struct afp_volume * volume, const char *path, struct afp_file_info **fb) { int ret=0; char converted_path[AFP_MAX_PATH]; if (convert_path_to_afp(volume->server->path_encoding, converted_path,(char *) path,AFP_MAX_PATH)) { return -EINVAL; } ret=appledouble_readdir(volume, converted_path, fb); if (ret<0) return ret; if (ret==1) goto done; return ll_readdir(volume,converted_path,fb,0); done: return 0; }