2 * All the functions related with dir, like open/read/closedir, are
5 * Copyright (C) 2009 Liu Aleaxander -- All rights reserved. This file
6 * can be redistributed under the terms of the GNU Public License.
13 #include "fstk_malloc.h"
16 DIR * this_dir
= NULL
;
18 DIR * fstk_opendir(struct fstk
*fs
, char *name
)
20 DIR *dir
= fstk_malloc(sizeof(*dir
));
23 malloc_error("DIR structure");
26 dir
->dd_dir
= fstk_open(fs
, name
);
36 struct dirent
*fstk_readdir(DIR *dir
)
38 struct fstk
*fs
= dir
->dd_dir
->fs
;
40 return fs
->ops
->readdir(dir
->dd_dir
);
44 void fstk_closedir(DIR *dir
)
48 fstk_close(dir
->dd_dir
);
53 void set_current_dentry(struct fstk
*fs
)
55 if (!(this_dir
= fstk_opendir(fs
, "/")))
56 printf("Warning: setting this_dir error\n");
59 void free_current_dentry(void)
62 fstk_closedir(this_dir
);