File: Dirstream.c

package info (click to toggle)
mlton 20041109-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 18,212 kB
  • ctags: 58,085
  • sloc: ansic: 10,386; makefile: 1,178; sh: 1,139; pascal: 256; asm: 97
file content (43 lines) | stat: -rw-r--r-- 966 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "platform.h"

enum {
	DEBUG_DIRSTREAM = FALSE,
};

Int Posix_FileSys_Dirstream_closedir (Cpointer p) {
	Int res;

	res = (Int)(closedir ((DIR *) p));
	if (DEBUG_DIRSTREAM)
		fprintf (stderr, "%d = closedir (0x%08x)\n", (uint)res, (uint)p);
	return res;
}

Cpointer Posix_FileSys_Dirstream_opendir (Cpointer p) {
	Cpointer res;

	res = (Cpointer)(opendir ((char *) p));
	if (DEBUG_DIRSTREAM)
		fprintf (stderr, "0x%08x = opendir (%s)\n", 
				(uint)res, (char *)p);
	return res;
}

Cstring Posix_FileSys_Dirstream_readdir (Cpointer d) {
	struct dirent *e;
	Cstring res;
	
	e = readdir ((DIR *) d);
	res = (Cstring)((NULL == e) ? NULL : e->d_name);
	if (DEBUG_DIRSTREAM)
		fprintf (stderr, "%s = readdir (0x%08x)\n", 
				((Cstring)NULL == res) ? "NULL": (char*)res,
				(uint)d);
	return res;
}

void Posix_FileSys_Dirstream_rewinddir (Cpointer p) {
	if (DEBUG_DIRSTREAM)
		fprintf (stderr, "rewinddir (0x%08x)\n", (uint)p);
       	rewinddir ((DIR *) p);
}