Home | History | Annotate | Download | only in lib

Lines Matching full:file

1 /* dirname.c -- return all but the last element in a file name
26 /* Return the length of the prefix of FILE that will be used by
27 dir_name. If FILE is in the working directory, this returns zero
28 even though 'dir_name (FILE)' will return ".". Works properly even
32 dir_len (char const *file)
34 size_t prefix_length = FILE_SYSTEM_PREFIX_LEN (file);
40 && ISSLASH (file[prefix_length]))
41 : (ISSLASH (file[0])
43 && ISSLASH (file[1]) && ! ISSLASH (file[2])
48 for (length = last_component (file) - file;
50 if (! ISSLASH (file[length - 1]))
60 Return the leading directories part of FILE, allocated with malloc.
64 If lstat (FILE) would succeed, then { chdir (dir_name (FILE));
65 lstat (base_name (FILE)); } will access the same file. Likewise,
66 if the sequence { chdir (dir_name (FILE));
67 rename (base_name (FILE), "foo"); } succeeds, you have renamed FILE
68 to "foo" in the same directory FILE was in. */
71 mdir_name (char const *file)
73 size_t length = dir_len (file);
76 && length == FILE_SYSTEM_PREFIX_LEN (file)
77 && file[2] != '\0' && ! ISSLASH (file[2])));
81 memcpy (dir, file, length);