t/unit-tests: fix typos
[git/gitster.git] / abspath.h
blob4653080d5e4b7aee7c5bc2a239c709012d6f6474
1 #ifndef ABSPATH_H
2 #define ABSPATH_H
4 int is_directory(const char *);
5 char *strbuf_realpath(struct strbuf *resolved, const char *path,
6 int die_on_error);
7 char *strbuf_realpath_forgiving(struct strbuf *resolved, const char *path,
8 int die_on_error);
9 char *real_pathdup(const char *path, int die_on_error);
10 const char *absolute_path(const char *path);
11 char *absolute_pathdup(const char *path);
14 * Concatenate "prefix" (if len is non-zero) and "path", with no
15 * connecting characters (so "prefix" should end with a "/").
16 * Unlike prefix_path, this should be used if the named file does
17 * not have to interact with index entry; i.e. name of a random file
18 * on the filesystem.
20 * The return value is always a newly allocated string (even if the
21 * prefix was empty).
23 char *prefix_filename(const char *prefix, const char *path);
25 /* Likewise, but path=="-" always yields "-" */
26 char *prefix_filename_except_for_dash(const char *prefix, const char *path);
28 static inline int is_absolute_path(const char *path)
30 return is_dir_sep(path[0]) || has_dos_drive_prefix(path);
33 /**
34 * Add a path to a buffer, converting a relative path to an
35 * absolute one in the process. Symbolic links are not
36 * resolved.
38 void strbuf_add_absolute_path(struct strbuf *sb, const char *path);
40 /**
41 * Canonize `path` (make it absolute, resolve symlinks, remove extra
42 * slashes) and append it to `sb`. Die with an informative error
43 * message if there is a problem.
45 * The directory part of `path` (i.e., everything up to the last
46 * dir_sep) must denote a valid, existing directory, but the last
47 * component need not exist.
49 * Callers that don't mind links should use the more lightweight
50 * strbuf_add_absolute_path() instead.
52 void strbuf_add_real_path(struct strbuf *sb, const char *path);
54 #endif /* ABSPATH_H */