Splitted POSIX based cfs implementation to avoid pulling in potentially large POSIX directory I/O functions without needing them at all.
This commit is contained in:
parent
102e3e2a24
commit
0564cc50fd
5 changed files with 90 additions and 48 deletions
|
@ -30,21 +30,15 @@
|
|||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: cfs-posix.c,v 1.6 2007/11/22 11:37:34 oliverschmidt Exp $
|
||||
* $Id: cfs-posix.c,v 1.7 2007/12/21 01:36:01 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cfs/cfs.h"
|
||||
|
||||
struct cfs_posix_dir {
|
||||
DIR *dirp;
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cfs_open(const char *n, int f)
|
||||
|
@ -76,40 +70,3 @@ cfs_seek(int f, unsigned int o)
|
|||
return lseek(f, o, SEEK_SET);
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cfs_opendir(struct cfs_dir *p, const char *n)
|
||||
{
|
||||
struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
|
||||
|
||||
dir->dirp = opendir(n);
|
||||
return dir->dirp == NULL;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
int
|
||||
cfs_readdir(struct cfs_dir *p, struct cfs_dirent *e)
|
||||
{
|
||||
struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
|
||||
struct dirent *res;
|
||||
|
||||
if(dir->dirp == NULL) {
|
||||
return -1;
|
||||
}
|
||||
res = readdir(dir->dirp);
|
||||
if(res == NULL) {
|
||||
return -1;
|
||||
}
|
||||
strncpy(e->name, res->d_name, sizeof(e->name));
|
||||
e->size = 0;
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
cfs_closedir(struct cfs_dir *p)
|
||||
{
|
||||
struct cfs_posix_dir *dir = (struct cfs_posix_dir *)p;
|
||||
|
||||
if(dir->dirp != NULL) {
|
||||
closedir(dir->dirp);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue