Path manipulation functions. More...
#include <stdbool.h>
#include <stdio.h>
Go to the source code of this file.
Functions | |
bool | mutt_path_abbr_folder (struct Buffer *path, const char *folder) |
Create a folder abbreviation. | |
const char * | mutt_path_basename (const char *path) |
Find the last component for a pathname. | |
bool | mutt_path_canon (struct Buffer *path, const char *homedir, bool is_dir) |
Create the canonical version of a path. | |
char * | mutt_path_dirname (const char *path) |
Return a path up to, but not including, the final '/'. | |
char * | mutt_path_escape (const char *src) |
Escapes single quotes in a path for a command string. | |
const char * | mutt_path_getcwd (struct Buffer *cwd) |
Get the current working directory. | |
size_t | mutt_path_realpath (struct Buffer *path) |
Resolve path, unraveling symlinks. | |
bool | mutt_path_tidy (struct Buffer *path, bool is_dir) |
Remove unnecessary parts of a path. | |
bool | mutt_path_tidy_dotdot (char *buf) |
Remove dot-dot-slash from a path. | |
bool | mutt_path_tidy_slash (char *buf, bool is_dir) |
Remove unnecessary slashes and dots. | |
bool | mutt_path_tilde (struct Buffer *path, const char *homedir) |
Expand '~' in a path. | |
bool | mutt_path_to_absolute (char *path, const char *reference) |
Convert a relative path to its absolute form. | |
Path manipulation functions.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Definition in file path.h.
bool mutt_path_abbr_folder | ( | struct Buffer * | path, |
const char * | folder | ||
) |
Create a folder abbreviation.
path | Path to modify |
folder | Base path for '=' substitution |
true | Path was abbreviated |
Abbreviate a path using '=' to represent the 'folder'. If the folder path is passed, it won't be abbreviated to just '='
Definition at line 399 of file path.c.
const char * mutt_path_basename | ( | const char * | path | ) |
Find the last component for a pathname.
path | String to be examined |
ptr | Part of pathname after last '/' character |
Definition at line 282 of file path.c.
bool mutt_path_canon | ( | struct Buffer * | path, |
const char * | homedir, | ||
bool | is_dir | ||
) |
Create the canonical version of a path.
path | Path to modify |
homedir | Home directory for '~' substitution |
is_dir | Is the path a directory? |
true | Success |
Remove unnecessary dots and slashes from a path and expand '~'.
Definition at line 248 of file path.c.
char * mutt_path_dirname | ( | const char * | path | ) |
Return a path up to, but not including, the final '/'.
path | Path |
ptr | The directory containing p |
Unlike the IEEE Std 1003.1-2001 specification of dirname(3), this implementation does not modify its parameter, so callers need not manually copy their paths into a modifiable buffer prior to calling this function.
Definition at line 312 of file path.c.
char * mutt_path_escape | ( | const char * | src | ) |
Escapes single quotes in a path for a command string.
src | the path to escape |
ptr | The escaped string |
Definition at line 433 of file path.c.
const char * mutt_path_getcwd | ( | struct Buffer * | cwd | ) |
Get the current working directory.
cwd | Buffer for the result |
ptr | String of current working directory |
Definition at line 476 of file path.c.
size_t mutt_path_realpath | ( | struct Buffer * | path | ) |
Resolve path, unraveling symlinks.
path | Buffer containing path |
num | String length of resolved path |
0 | Error, buf is not overwritten |
Resolve and overwrite the path in buf.
Definition at line 377 of file path.c.
bool mutt_path_tidy | ( | struct Buffer * | path, |
bool | is_dir | ||
) |
Remove unnecessary parts of a path.
[in,out] | path | Path to modify |
[in] | is_dir | Is the path a directory? |
true | Success |
Remove unnecessary dots and slashes from a path
Definition at line 169 of file path.c.
bool mutt_path_tidy_dotdot | ( | char * | buf | ) |
Remove dot-dot-slash from a path.
[in,out] | buf | Path to modify |
true | Success |
Collapse dot-dot patterns, like '/dir/../'
Definition at line 109 of file path.c.
bool mutt_path_tidy_slash | ( | char * | buf, |
bool | is_dir | ||
) |
Remove unnecessary slashes and dots.
[in,out] | buf | Path to modify |
[in] | is_dir | Should a trailing / be removed? |
true | Success |
Collapse repeated '//' and '/./'
Definition at line 58 of file path.c.
bool mutt_path_tilde | ( | struct Buffer * | path, |
const char * | homedir | ||
) |
Expand '~' in a path.
path | Path to modify |
homedir | Home directory for '~' substitution |
true | Success |
Behaviour:
~/dir
(~ expanded)~realuser/dir
(~realuser expanded)~nonuser/dir
(~nonuser not changed) Definition at line 194 of file path.c.
bool mutt_path_to_absolute | ( | char * | path, |
const char * | reference | ||
) |
Convert a relative path to its absolute form.
[in,out] | path | Relative path |
[in] | reference | Absolute path that path is relative to |
true | Success, path was changed into its absolute form |
false | Failure, path is untouched |
Use POSIX functions to convert a path to absolute, relatively to another path
Definition at line 333 of file path.c.