aboutsummaryrefslogtreecommitdiffstats
path: root/src/path.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-29 03:05:14 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-29 03:05:14 -0700
commitc4772b46eedc41cbe40678be1c02f31d24117b5e (patch)
treea43100a40f5f30d95dabacd98a9e372930b5bc5e /src/path.c
parent1e36728aedede8f521b622ef32ca102e79cb61f6 (diff)
parentdde461fe6e012a62ee47cf5f3bfc022b650b6bf5 (diff)
downloadmpd-c4772b46eedc41cbe40678be1c02f31d24117b5e.tar.gz
mpd-c4772b46eedc41cbe40678be1c02f31d24117b5e.tar.xz
mpd-c4772b46eedc41cbe40678be1c02f31d24117b5e.zip
Merge branch 'ew/directory'
* ew/directory: directory: remove redundant sanitizePathDup update: move path sanitation up the stack to avoid extra copies clean up updateInit calling and error handling directory: isRootDirectory() is a one-liner directory: writeDirectoryInfo propagates errors directory: make it clear that DIRECTORY_MTIME is deprecated directory: remove "Mp3" references playlist: deleteASongFromPlaylist takes a const Song * songvec: songvec_delete takes a const Song pointer directory: remove shortname arguments everywhere path: add mpd_basename() function directory.h: remove directory_sigChldHandler decl directory: replace DirectoryList with dirvec directory: remove unused CPP defines songvec_free => songvec_destroy directory.c: kill unnecessary includes
Diffstat (limited to 'src/path.c')
-rw-r--r--src/path.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/path.c b/src/path.c
index ceb00c5de..8d1b0018d 100644
--- a/src/path.c
+++ b/src/path.c
@@ -290,3 +290,15 @@ void utf8_to_fs_playlist_path(char *path_max_tmp, const char *utf8path)
rpp2app_r(path_max_tmp, path_max_tmp);
strncat(path_max_tmp, "." PLAYLIST_FILE_SUFFIX, MPD_PATH_MAX - 1);
}
+
+/* Only takes sanitized paths w/o trailing slashes */
+const char *mpd_basename(const char *path)
+{
+ const char *ret = strrchr(path, '/');
+
+ if (!ret)
+ return path;
+ ++ret;
+ assert(*ret != '\0');
+ return ret;
+}