NeoMutt  2025-01-09-117-gace867
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
path.c File Reference

Type representing a path. More...

#include "config.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "mutt/lib.h"
#include "core/lib.h"
#include "set.h"
#include "types.h"
+ Include dependency graph for path.c:

Go to the source code of this file.

Functions

static char * path_tidy (const char *path, bool is_dir)
 Tidy a path for storage.
 
static void path_destroy (void *var, const struct ConfigDef *cdef)
 Destroy a Path - Implements ConfigSetType::destroy() -.
 
static int path_string_set (void *var, struct ConfigDef *cdef, const char *value, struct Buffer *err)
 Set a Path by string - Implements ConfigSetType::string_set() -.
 
static int path_string_get (void *var, const struct ConfigDef *cdef, struct Buffer *result)
 Get a Path as a string - Implements ConfigSetType::string_get() -.
 
static int path_native_set (void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
 Set a Path config item by string - Implements ConfigSetType::native_set() -.
 
static intptr_t path_native_get (void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Get a string from a Path config item - Implements ConfigSetType::native_get() -.
 
static bool path_has_been_set (void *var, const struct ConfigDef *cdef)
 Is the config value different to its initial value? - Implements ConfigSetType::has_been_set() -.
 
static int path_reset (void *var, const struct ConfigDef *cdef, struct Buffer *err)
 Reset a Path to its initial value - Implements ConfigSetType::reset() -.
 

Variables

const struct ConfigSetType CstPath
 Config type representing a path.
 

Detailed Description

Type representing a path.

Authors
  • Pietro Cerutti
  • Richard Russon
  • Dennis Schön
  • наб

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.c.

Function Documentation

◆ path_tidy()

static char * path_tidy ( const char *  path,
bool  is_dir 
)
static

Tidy a path for storage.

Parameters
pathPath to be tidied
is_dirIs the path a directory?
Return values
ptrTidy path

Expand ~ and remove junk like /./

Note
The caller must free the returned string

Definition at line 57 of file path.c.

58{
59 if (!path || (*path == '\0'))
60 return NULL;
61
62 struct Buffer *buf = buf_pool_get();
63 buf_strcpy(buf, path);
64
66 mutt_path_tidy(buf, is_dir);
67
68 char *tidy_path = buf_strdup(buf);
69 buf_pool_release(&buf);
70
71 return tidy_path;
72}
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
Definition: buffer.c:395
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:571
bool mutt_path_tidy(struct Buffer *path, bool is_dir)
Remove unnecessary parts of a path.
Definition: path.c:169
bool mutt_path_tilde(struct Buffer *path, const char *homedir)
Expand '~' in a path.
Definition: path.c:194
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
String manipulation buffer.
Definition: buffer.h:36
Container for Accounts, Notifications.
Definition: neomutt.h:43
char * home_dir
User's home directory.
Definition: neomutt.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ CstPath

const struct ConfigSetType CstPath
Initial value:
= {
"path",
NULL,
NULL,
}
static void path_destroy(void *var, const struct ConfigDef *cdef)
Destroy a Path - Implements ConfigSetType::destroy() -.
Definition: path.c:77
static bool path_has_been_set(void *var, const struct ConfigDef *cdef)
Is the config value different to its initial value? - Implements ConfigSetType::has_been_set() -.
Definition: path.c:217
static intptr_t path_native_get(void *var, const struct ConfigDef *cdef, struct Buffer *err)
Get a string from a Path config item - Implements ConfigSetType::native_get() -.
Definition: path.c:207
static int path_native_set(void *var, const struct ConfigDef *cdef, intptr_t value, struct Buffer *err)
Set a Path config item by string - Implements ConfigSetType::native_set() -.
Definition: path.c:162
static int path_reset(void *var, const struct ConfigDef *cdef, struct Buffer *err)
Reset a Path to its initial value - Implements ConfigSetType::reset() -.
Definition: path.c:230
static int path_string_get(void *var, const struct ConfigDef *cdef, struct Buffer *result)
Get a Path as a string - Implements ConfigSetType::string_get() -.
Definition: path.c:143
static int path_string_set(void *var, struct ConfigDef *cdef, const char *value, struct Buffer *err)
Set a Path by string - Implements ConfigSetType::string_set() -.
Definition: path.c:89
@ DT_PATH
a path to a file/directory
Definition: types.h:39

Config type representing a path.

Definition at line 273 of file path.c.