1
0
Fork 0
forked from len0rd/rockbox

RaaA: Improve tagcache search to make the database built.

First, it add the ability to tagcache to walk through multiple search roots.
Second, it adds symlinks targets to the search roots if they're are not inside any of the current search roots, otherwise the symlink is ignored (unless it's a file).

The default search root is still /, so no search root will be actually added.
But the tagcache now isn't trapped by recursive symlinks anymore and successfully builds, and it's prepared for a future music directory setting.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28884 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2010-12-23 19:02:18 +00:00
parent e1b1183f40
commit 87c8be4a08
4 changed files with 165 additions and 39 deletions

View file

@ -105,26 +105,37 @@ struct dirinfo dir_get_info(struct DIR* _parent, struct dirent *dir)
{
struct __dir *parent = (struct __dir*)_parent;
struct stat s;
struct tm *tm;
struct tm *tm = NULL;
struct dirinfo ret;
char path[MAX_PATH];
snprintf(path, sizeof(path), "%s/%s", parent->path, dir->d_name);
stat(path, &s);
memset(&ret, 0, sizeof(ret));
if (S_ISDIR(s.st_mode))
if (!stat(path, &s))
{
ret.attribute = ATTR_DIRECTORY;
if (S_ISDIR(s.st_mode))
{
ret.attribute = ATTR_DIRECTORY;
}
ret.size = s.st_size;
tm = localtime(&(s.st_mtime));
}
if (!lstat(path, &s) && S_ISLNK(s.st_mode))
{
ret.attribute |= ATTR_LINK;
}
if (tm)
{
ret.wrtdate = ((tm->tm_year - 80) << 9) |
((tm->tm_mon + 1) << 5) |
tm->tm_mday;
ret.wrttime = (tm->tm_hour << 11) |
(tm->tm_min << 5) |
(tm->tm_sec >> 1);
}
ret.size = s.st_size;
tm = localtime(&(s.st_mtime));
ret.wrtdate = ((tm->tm_year - 80) << 9) |
((tm->tm_mon + 1) << 5) |
tm->tm_mday;
ret.wrttime = (tm->tm_hour << 11) |
(tm->tm_min << 5) |
(tm->tm_sec >> 1);
return ret;
}