-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
146 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <sys/syscall.h> | ||
#include <dirent.h> | ||
|
||
DIR *opendir(const char *name) | ||
{ | ||
DIR *dir = malloc(sizeof(DIR)); | ||
dir->idx = 0; | ||
|
||
sys$$readdir_param param; | ||
param.dir = name; | ||
param.dst = dir->data; | ||
param.dstSize = 256; | ||
int result = syscall(SYS_READDIR, ¶m); | ||
if (result < 0) | ||
{ | ||
free(dir); | ||
return NULL; | ||
} | ||
dir->max = result; | ||
return dir; | ||
} | ||
|
||
int closedir(DIR *dir) | ||
{ | ||
free(dir); | ||
} | ||
|
||
dirent *readdir(DIR *dir) | ||
{ | ||
if (dir->idx >= dir->max) | ||
return NULL; | ||
dirent *d = &dir->data[dir->idx]; | ||
dir->idx++; | ||
return d; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef _DIRENT_H | ||
#define _DIRENT_H | ||
|
||
#include <stddef.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
#define TYPE_FILE 0 | ||
#define TYPE_DIR 1 | ||
|
||
typedef struct | ||
{ | ||
char name[256]; | ||
size_t size; | ||
unsigned type; | ||
} dirent; | ||
|
||
typedef struct | ||
{ | ||
dirent data[256]; | ||
size_t idx; | ||
size_t max; | ||
} DIR; | ||
|
||
DIR *opendir(const char *name); | ||
int closedir(DIR *); | ||
dirent *readdir(DIR *); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters