#include #include "ostool.h" #include "commun.h" /* recherche un fichier en revenant vers la racine (r‚pertoires virtuels). Si le fichier n'est dans le path fournis, remonte d'un repertoire et essai. Retourne 0 si ok, -1 si erreur. */ export int vdir_findanc ( const char *path, /* path ou on pense trouver le fichier */ /* "" -> path courant */ const char *nom, /* nom du fichier ou du repertoire */ char *filepath, /* contiendra le path trouve pour ce fichier */ /* peut ˆtre NULL */ char *pathreel) /* contiendra le path reel (dans l'archive) */ /* peut ˆtre NULL */ { int ret = -1; char wpath[MAXSIZ_PATH]; char tmpfpath[MAXSIZ_PATH]; if (filepath == NULL) filepath = tmpfpath; path_addback (path,wpath); if (path_setabs (wpath,wpath)!=-1){ while (1){ path_make (wpath,nom,filepath); if (vdir_ftype(filepath,pathreel) >= 0){ ret = 0; break; }else if(path_isroot(wpath)){ break; }else{ int len = strlen(wpath); path_stripsep (wpath,wpath); path_splitlex (wpath,wpath,NULL); if ((int)strlen(wpath)==len) break; } } } return ret; } /* recherche un fichier ou un repertoire en revenant vers la racine Si le fichier n'est pas dans le path fournis, remonte d'un repertoire et essai. Retourne 0 si ok, -1 si erreur. */ export int vdir_findancp ( const char *fpath, /* path du fichier ou r‚pertoire cherch‚ */ char *fname, /* path o— il … ‚t‚ trouv‚ */ char *pathreel) /* contiendra le path reel (dans l'archive) */ /* peut ˆtre NULL */ { char path[MAXSIZ_PATH]; char name[MAXSIZ_NAME]; path_splitlex (fpath,path,name); return vdir_findanc(path,name,fname,pathreel); }