Search for a name in the file list. You must specify want_dir_match as: * 1=match directories, 0=match non-directories, or -1=match either. */
| 2876 | /* Search for a name in the file list. You must specify want_dir_match as: |
| 2877 | * 1=match directories, 0=match non-directories, or -1=match either. */ |
| 2878 | int flist_find_name(struct file_list *flist, const char *fname, int want_dir_match) |
| 2879 | { |
| 2880 | static struct file_struct *f; |
| 2881 | char fbuf[MAXPATHLEN]; |
| 2882 | const char *slash = strrchr(fname, '/'); |
| 2883 | const char *basename = slash ? slash+1 : fname; |
| 2884 | |
| 2885 | if (!f) |
| 2886 | f = (struct file_struct*)new_array(char, FILE_STRUCT_LEN + MAXPATHLEN + 1); |
| 2887 | |
| 2888 | memset(f, 0, FILE_STRUCT_LEN); |
| 2889 | memcpy((void*)f->basename, basename, strlen(basename)+1); |
| 2890 | |
| 2891 | if (slash) { |
| 2892 | strlcpy(fbuf, fname, slash - fname + 1); |
| 2893 | f->dirname = fbuf; |
| 2894 | } else |
| 2895 | f->dirname = NULL; |
| 2896 | |
| 2897 | f->mode = want_dir_match > 0 ? S_IFDIR : S_IFREG; |
| 2898 | |
| 2899 | if (want_dir_match < 0) |
| 2900 | return flist_find_ignore_dirness(flist, f); |
| 2901 | return flist_find(flist, f); |
| 2902 | } |
| 2903 | |
| 2904 | /* Search for an identically-named item in the file list. Differs from |
| 2905 | * flist_find in that an item that agrees with "f" in directory-ness is |
no test coverage detected