From e0637255341a165e1e186e6f2836c614f0121c8b Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Mon, 20 Jun 2011 20:12:15 +0000 Subject: Dircache: Return the size of the result string in dircache_copy_path() so that callers don't need to call strlen on it. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30034 a1c6a512-1295-4272-9138-f99709370657 --- firmware/common/dircache.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'firmware/common/dircache.c') diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index dc662bb9cd..3eae85ee3b 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -932,16 +932,19 @@ static size_t copy_path_helper(const struct dircache_entry *entry, char *buf, si /** * Function to copy the full absolute path from dircache to the given buffer * using the given dircache_entry pointer. + * + * Returns the size of the resulting string, or 0 if an error occured */ -void dircache_copy_path(const struct dircache_entry *entry, char *buf, int size) +size_t dircache_copy_path(const struct dircache_entry *entry, char *buf, size_t size) { - if (size <= 0 || !buf) - return ; + if (!size || !buf) + return 0; buf[0] = '/'; size_t res = copy_path_helper(entry, buf, size); /* fixup trailing '/' */ buf[res] = '\0'; + return res; } /* --- Directory cache live updating functions --- */ -- cgit v1.2.3