68 for (; (r[0] ==
'/') || (r[0] ==
'.'); r++)
79 else if (r[1] ==
'\0')
90 if (is_dir && (w > (buf + 1)) && (w[-1] ==
'/'))
107 if (!buf || (buf[0] !=
'/'))
113 while ((dd = strstr(dd,
"/..")))
121 dest = strrchr(buf,
'/');
126 memmove(dest, dd + 3, strlen(dd + 3) + 1);
128 else if (dd[3] ==
'\0')
137 char *s = strrchr(buf,
'/');
167 if (!buf || (buf[0] !=
'/'))
197 if ((buf[len] !=
'/') && (buf[len] !=
'\0'))
201 if (buf[len] ==
'\0')
225 if (!buf || (buf[0] !=
'~'))
232 if ((buf[1] ==
'/') || (buf[1] ==
'\0'))
245 char user[128] = { 0 };
246 dir = strchr(buf + 1,
'/');
252 struct passwd *pw = getpwnam(user);
253 if (!pw || !pw->pw_dir)
263 if ((len + dirlen) >= buflen)
296 else if (buf[0] !=
'/')
298 if (!getcwd(result,
sizeof(result)))
306 if ((cwdlen + dirlen + 1) >= buflen)
309 cwdlen + dirlen + 1, buflen);
313 result[cwdlen] =
'/';
314 mutt_str_copy(result + cwdlen + 1, buf,
sizeof(result) - cwdlen - 1);
334 const char *p = strrchr(f,
'/');
353 if (!d || !dir || !fname)
356 const char *fmt =
"%s/%s";
358 if ((fname[0] ==
'\0') || ((dir[0] !=
'\0') && (dir[strlen(dir) - 1] ==
'/')))
361 snprintf(d, l, fmt, dir, fname);
399 if (!path || !reference)
406 if ((strlen(path) > 1) && (path[0] ==
'/'))
416 path_len =
sizeof(abs_path) - strlen(path);
418 mutt_strn_cat(abs_path,
sizeof(abs_path), path, (path_len > 0) ? path_len : 0);
420 path = realpath(abs_path, path);
421 if (!path && (errno != ENOENT))
447 if (!realpath(buf, s))
467 if (buf[n - 1] ==
'/')
471 for (n--; ((n >= 0) && (buf[n] !=
'/')); n--)
499 if (folder[flen - 1] ==
'/')
505 if (buf[flen + 1] ==
'\0')
511 memmove(buf + 1, buf + flen + 1, rlen + 1);
529 while (*src && (destsize <
sizeof(dest) - 1))
539 if (destsize + 4 <
sizeof(dest))
567 char *retval = getcwd(cwd->
data, cwd->
dsize);
568 while (!retval && (errno == ERANGE))
void mutt_buffer_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
void mutt_buffer_fix_dptr(struct Buffer *buf)
Move the dptr to end of the Buffer.
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
General purpose object for storing and parsing strings.
#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.
bool mutt_path_tidy(char *buf, bool is_dir)
Remove unnecessary parts of a path.
const char * mutt_path_basename(const char *f)
Find the last component for a pathname.
bool mutt_path_tilde(char *buf, size_t buflen, const char *homedir)
Expand '~' in a path.
char * mutt_path_concat(char *d, const char *dir, const char *fname, size_t l)
Join a directory name and a filename.
bool mutt_path_to_absolute(char *path, const char *reference)
Convert relative filepath to an absolute path.
bool mutt_path_abbr_folder(char *buf, const char *folder)
Create a folder abbreviation.
char * mutt_path_escape(const char *src)
Escapes single quotes in a path for a command string.
bool mutt_path_pretty(char *buf, size_t buflen, const char *homedir, bool is_dir)
Tidy a filesystem path.
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_canon(char *buf, size_t buflen, const char *homedir, bool is_dir)
Create the canonical version of a path.
const char * mutt_path_getcwd(struct Buffer *cwd)
Get the current working directory.
bool mutt_path_parent(char *buf)
Find the parent of a path.
size_t mutt_path_realpath(char *buf)
Resolve path, unraveling symlinks.
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.
char * mutt_strn_cat(char *d, size_t l, const char *s, size_t sl)
Concatenate two strings.
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
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)
Path manipulation functions.
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.