Converted module.c to use sys_read_dir() instead of sys_read(). But it really
should use opendir(), and readdir(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@60 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+14
-13
@@ -425,16 +425,17 @@ static int recurse_check_file(const char *filepath, const char *srcfile)
|
|||||||
*/
|
*/
|
||||||
static int recurse_directory(const char *path, const char *match)
|
static int recurse_directory(const char *path, const char *match)
|
||||||
{
|
{
|
||||||
|
/* ToDo: should just use opendir(), readdir(), ... */
|
||||||
struct stat stat;
|
struct stat stat;
|
||||||
int res = 0, file;
|
int res = 0, dir;
|
||||||
char *name;
|
int bufferSize = sizeof(struct dirent) + SYS_MAX_NAME_LEN + 1;
|
||||||
|
struct dirent *dirent;
|
||||||
|
|
||||||
if ((file = sys_open(path, STREAM_TYPE_DIR, 0)) < 0) {
|
if ((dir = sys_open(path, STREAM_TYPE_DIR, 0)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
name = (char*)kmalloc(SYS_MAX_NAME_LEN);
|
dirent = kmalloc(bufferSize);
|
||||||
if (!name)
|
if (!dirent)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* loop until we have a match or we run out of entries */
|
/* loop until we have a match or we run out of entries */
|
||||||
@@ -443,16 +444,16 @@ static int recurse_directory(const char *path, const char *match)
|
|||||||
size_t slen = 0;
|
size_t slen = 0;
|
||||||
SHOW_FLOW(3, "scanning %s\n", path);
|
SHOW_FLOW(3, "scanning %s\n", path);
|
||||||
|
|
||||||
name[0] = '\0';
|
if ((res = sys_read_dir(dir, dirent, bufferSize, 1)) <= 0)
|
||||||
if ((res = sys_read(file, name, 0, SYS_MAX_NAME_LEN)) <= 0) {
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
slen = strlen(path) + strlen(name) + 2;
|
dirent->d_name[dirent->d_reclen] = '\0';
|
||||||
|
|
||||||
|
slen = strlen(path) + strlen(dirent->d_name) + 2;
|
||||||
newpath = (char*)kmalloc(slen);
|
newpath = (char*)kmalloc(slen);
|
||||||
strlcpy(newpath, path, slen);
|
strlcpy(newpath, path, slen);
|
||||||
strlcat(newpath, "/", slen);
|
strlcat(newpath, "/", slen);
|
||||||
strlcat(newpath, name, slen);
|
strlcat(newpath, dirent->d_name, slen);
|
||||||
|
|
||||||
if ((res = sys_rstat(newpath, &stat)) != B_NO_ERROR) {
|
if ((res = sys_rstat(newpath, &stat)) != B_NO_ERROR) {
|
||||||
kfree(newpath);
|
kfree(newpath);
|
||||||
@@ -481,8 +482,8 @@ static int recurse_directory(const char *path, const char *match)
|
|||||||
kfree(newpath);
|
kfree(newpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(name);
|
kfree(dirent);
|
||||||
sys_close(file);
|
sys_close(dir);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user