On Sat, Nov 20, 2010 at 09:21:34PM +0100, Clément Bœsch wrote:
+ * \brief Allocates a new buffer containing the directory name + * \param path Original path. Must be a valid string. + * + * The path returned always contains a trailing slash '/'. + * On systems supporting DOS paths, '\' is also considered as a directory + * separator in addition to the '/'. + */ +char *mp_dirname(const char *path) +{ + const char *base = mp_basename(path); + size_t len = base - path; + char *dirname; + + if (len == 0) + return strdup("./"); + dirname = malloc(len + 1); + if (!dirname) + return NULL; + strncpy(dirname, path, len); + dirname[len] = '\0';
Not sure if it is an improvement, but you could do both in one by using av_strlcpy(dirname, path, len + 1); Either way, that part is ok. Except for one thing I noticed while looking through the next patch: For DOS paths you must also consider ':' a path separator in mp_basename, so that c:test.avi is treated correctly.
From 3ebc481e5eae0e7ffe328d6e23d45cbd250b9994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux@gmail.com> Date: Sat, 20 Nov 2010 21:07:43 +0100 Subject: [PATCH 2/3] Make load of n subtitles directories possible
Could you please explain what you are changing and why? Adding doxygen descriptions to all new functions might help as well.