72 for (; (r[0] ==
'/') || (r[0] ==
'.'); r++)
83 else if (r[1] ==
'\0')
94 if (is_dir && (w > (buf + 1)) && (w[-1] ==
'/'))
111 if (!buf || (buf[0] !=
'/'))
117 while ((dd = strstr(dd,
"/..")))
125 dest = strrchr(buf,
'/');
130 memmove(dest, dd + 3, strlen(dd + 3) + 1);
132 else if (dd[3] ==
'\0')
141 char *s = strrchr(buf,
'/');
203 if ((
buf_at(path, 1) ==
'/') || (
buf_at(path, 1) ==
'\0'))
212 dir = path->
data + 1;
216 char user[128] = { 0 };
217 dir = strchr(path->
data + 1,
'/');
223 struct passwd *pw = getpwnam(user);
224 if (!pw || !pw->pw_dir)
253 if (
buf_at(path, 0) ==
'~')
257 else if (
buf_at(path, 0) !=
'/')
260 if (!getcwd(cwd,
sizeof(cwd)))
268 cwd[cwd_len + 1] =
'\0';
287 const char *p = strrchr(path,
'/');
335 if (!path || !reference)
339 if ((strlen(path) > 1) && (path[0] ==
'/'))
351 const char *result = realpath(
buf_string(abs_path), rpath);
408 if (folder[flen - 1] ==
'/')
414 if (
buf_at(path, flen + 1) ==
'\0')
420 memmove(path->
data + 1, path->
data + flen + 1, rlen + 1);
442 while (*src && (destsize <
sizeof(dest) - 1))
452 if ((destsize + 4) <
sizeof(dest))
482 char *rc = getcwd(cwd->
data, cwd->
dsize);
483 while (!rc && (errno == ERANGE))
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
void buf_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
size_t buf_insert(struct Buffer *buf, size_t offset, const char *s)
Add a string in the middle of a buffer.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
General purpose object for storing and parsing strings.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
#define mutt_debug(LEVEL,...)
@ LL_DEBUG3
Log at debug level 3.
@ LL_DEBUG1
Log at debug level 1.
Memory management wrappers.
bool mutt_path_tidy_dotdot(char *buf)
Remove dot-dot-slash from a path.
const char * mutt_path_basename(const char *path)
Find the last component for a pathname.
bool mutt_path_tidy(struct Buffer *path, bool is_dir)
Remove unnecessary parts of a path.
bool mutt_path_to_absolute(char *path, const char *reference)
Convert a relative path to its absolute form.
bool mutt_path_canon(struct Buffer *path, const char *homedir, bool is_dir)
Create the canonical version of a path.
char * mutt_path_escape(const char *src)
Escapes single quotes in a path for a command string.
char * mutt_path_dirname(const char *path)
Return a path up to, but not including, the final '/'.
bool mutt_path_tidy_slash(char *buf, bool is_dir)
Remove unnecessary slashes and dots.
bool mutt_path_abbr_folder(struct Buffer *path, const char *folder)
Create a folder abbreviation.
size_t mutt_path_realpath(struct Buffer *path)
Resolve path, unraveling symlinks.
bool mutt_path_tilde(struct Buffer *path, const char *homedir)
Expand '~' in a path.
const char * mutt_path_getcwd(struct Buffer *cwd)
Get the current working directory.
Path manipulation functions.
char * mutt_str_dup(const char *str)
Copy a string, safely.
bool mutt_strn_equal(const char *a, const char *b, size_t num)
Check for equality of two strings (to a maximum), safely.
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
A global pool of Buffers.
String manipulation functions.
#define STR_COMMAND
Enough space for a long command line.
String manipulation buffer.
size_t dsize
Length of data.
char * data
Pointer to data.