mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
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
This commit is contained in:
parent
38da400e58
commit
e063725534
4 changed files with 11 additions and 8 deletions
|
|
@ -1353,8 +1353,8 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
|
||||||
{
|
{
|
||||||
if (playlist->filenames[index] != NULL)
|
if (playlist->filenames[index] != NULL)
|
||||||
{
|
{
|
||||||
dircache_copy_path(playlist->filenames[index], tmp_buf, sizeof(tmp_buf)-1);
|
max = dircache_copy_path(playlist->filenames[index],
|
||||||
max = strlen(tmp_buf);
|
tmp_buf, sizeof(tmp_buf)-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -1481,10 +1481,10 @@ static bool get_next(struct tagcache_search *tcs)
|
||||||
if (tcs->type == tag_filename && (flag & FLAG_DIRCACHE)
|
if (tcs->type == tag_filename && (flag & FLAG_DIRCACHE)
|
||||||
&& is_dircache_intact())
|
&& is_dircache_intact())
|
||||||
{
|
{
|
||||||
dircache_copy_path((struct dircache_entry *)tcs->position,
|
size_t len = dircache_copy_path((struct dircache_entry *)tcs->position,
|
||||||
buf, sizeof buf);
|
buf, sizeof buf);
|
||||||
|
tcs->result_len = len + 1;
|
||||||
tcs->result = buf;
|
tcs->result = buf;
|
||||||
tcs->result_len = strlen(buf) + 1;
|
|
||||||
tcs->ramresult = false;
|
tcs->ramresult = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -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
|
* Function to copy the full absolute path from dircache to the given buffer
|
||||||
* using the given dircache_entry pointer.
|
* 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)
|
if (!size || !buf)
|
||||||
return ;
|
return 0;
|
||||||
|
|
||||||
buf[0] = '/';
|
buf[0] = '/';
|
||||||
size_t res = copy_path_helper(entry, buf, size);
|
size_t res = copy_path_helper(entry, buf, size);
|
||||||
/* fixup trailing '/' */
|
/* fixup trailing '/' */
|
||||||
buf[res] = '\0';
|
buf[res] = '\0';
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --- Directory cache live updating functions --- */
|
/* --- Directory cache live updating functions --- */
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ int dircache_get_reserve_used(void);
|
||||||
int dircache_get_build_ticks(void);
|
int dircache_get_build_ticks(void);
|
||||||
void dircache_disable(void);
|
void dircache_disable(void);
|
||||||
const struct dircache_entry *dircache_get_entry_ptr(const char *filename);
|
const struct dircache_entry *dircache_get_entry_ptr(const char *filename);
|
||||||
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);
|
||||||
|
|
||||||
void dircache_bind(int fd, const char *path);
|
void dircache_bind(int fd, const char *path);
|
||||||
void dircache_update_filesize(int fd, long newsize, long startcluster);
|
void dircache_update_filesize(int fd, long newsize, long startcluster);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue