index 8b0fc0058d30c7ae1f699bcf69d5b42eba55dbbb..76c7a5b8f8b3e096ebedf2748683ef6a4a4b9cbb 100644 (file)
MODULE HostFiles;
- IMPORT S := SYSTEM, Kernel, HostLang, Files, Log, stdlib := C99stdlib,
- unistd := C99unistd, dirent := C99dirent, fcntl := C99fcntl,
- sysstat := C99sys_stat, stdio := C99stdio, errno := C99errno,
- macro := C99macro, libgen := C99libgen, time := C99time;
+ IMPORT S := SYSTEM, Kernel, HostLang, Files, Log, stdlib := PosixCstdlib,
+ unistd := PosixCunistd, dirent := PosixCdirent, fcntl := PosixCfcntl,
+ sysstat := PosixCsys_stat, stdio := PosixCstdio, errno := PosixCerrno,
+ macro := PosixCmacro, libgen := PosixClibgen, time := PosixCtime;
(* !!! add buffer cache *)
+ (* !!! HostFiles64 must be base for HostFiles *)
CONST
closed = 0; new = 1; temp = 2; shared = 3; exclusive = 4;
File = POINTER TO RECORD (Files.File)
state: INTEGER;
- len: INTEGER;
+ len: INTEGER; (* !!! must be sysstat.off_t *)
fd: unistd.int;
ino: sysstat.ino_t;
pathname: FullName
ASSERT(f.state = new, 20);
ASSERT(name # "", 21);
ASSERT(IsName(name), 22);
- HostLang.StringToHost(f.pathname, p0, FALSE, err);
+ HostLang.StringToHost(f.pathname, p0, HostLang.pep383, err);
IF err = 0 THEN
dir := f.pathname$;
DirName(dir);
- HostLang.StringToHost(dir + "/" + name, p1, FALSE, err);
+ HostLang.StringToHost(dir + "/" + name, p1, HostLang.pep383, err);
IF err = 0 THEN
x := stdio.rename(p0, p1);
IF x = 0 THEN res := 0 (* no error *)
IF f.state # closed THEN
f.Flush;
IF f.state = new THEN
- HostLang.StringToHost(f.pathname, path, FALSE, err);
+ HostLang.StringToHost(f.pathname, path, HostLang.pep383, err);
ASSERT(err = 0, 100);
res := unistd.unlink(path);
ASSERT(res = 0, 101);
VAR i: INTEGER; sep: BOOLEAN; err: unistd.int; s: sysstat.struct_stat; mode: sysstat.mode_t;
BEGIN
i := 0; err := 0;
- mode := ORD(BITS(511(*a=rwx*)) - BITS(sysstat.umask(0)));
+ mode := S.VAL((*!!!*)sysstat.mode_t, ORD(BITS(511(*a=rwx*)) - BITS(sysstat.umask(0))));
WHILE (err = 0) & (path[i] # 0X) DO
WHILE (path[i] # "/") & (path[i] # 0X) DO INC(i) END;
sep := path[i] = "/";
BEGIN
ASSERT(loc # NIL, 20);
WITH loc: Locator DO
- HostLang.StringToHost(loc.path, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path, pathname, HostLang.pep383, err);
IF err = 0 THEN
MakeDir(pathname, res);
IF res = 0 THEN
pathname := pathname + "/" + ".newXXXXXX";
fd := stdlib.mkstemp(pathname);
IF fd # -1 THEN
- NEW(f); HostLang.HostToString(pathname, f.pathname, FALSE, err);
+ NEW(f); HostLang.HostToString(pathname, f.pathname, HostLang.pep383, err);
IF err = 0 THEN
(* !!! get valid inode? *)
f.fd := fd; f.len := 0; f.state := new; f.ino := 0;
ASSERT(name # "", 21);
WITH loc: Locator DO
IF IsName(name) THEN
- HostLang.StringToHost(loc.path + "/" + name, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + name, pathname, HostLang.pep383, err);
IF err = 0 THEN
res := macro.stat(pathname, s);
IF res = 0 THEN
IF IsRegFile(s) THEN
if := GetFileByInode(s.st_ino);
IF (if = NIL) OR isShared & (if.state = shared) THEN
- mode := ORD(BITS(rwrwrw) - BITS(sysstat.umask(0)));
+ mode := S.VAL((*!!!*)sysstat.mode_t, ORD(BITS(rwrwrw) - BITS(sysstat.umask(0))));
IF isShared THEN flags := fcntl.O_RDONLY
ELSE flags := fcntl.O_RDWR
END;
lock.l_pid := 0;
res := fcntl.fcntl(fd, fcntl.F_SETLK, S.ADR(lock));
IF res # -1 THEN
- NEW(f); HostLang.HostToString(pathname, f.pathname, FALSE, err);
+ NEW(f); HostLang.HostToString(pathname, f.pathname, HostLang.pep383, err);
IF err = 0 THEN
- f.fd := fd; f.len := s.st_size; f.ino := s.st_ino;
+ f.fd := fd; f.len := S.VAL((*!!!*)INTEGER, s.st_size); f.ino := s.st_ino;
IF isShared THEN f.state := shared
ELSE f.state := exclusive
END;
ASSERT(IsName(name), 21);
WITH loc: Locator DO
IF IsName(name) THEN
- HostLang.StringToHost(loc.path + "/" + name, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + name, pathname, HostLang.pep383, err);
IF err = 0 THEN
res := unistd.unlink(pathname);
IF res = 0 THEN loc.res := 0 (* no error *)
ASSERT(new # "", 22);
WITH loc: Locator DO
IF IsName(old) & IsName(new) THEN
- HostLang.StringToHost(loc.path + "/" + old, p0, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + old, p0, HostLang.pep383, err);
IF err = 0 THEN
- HostLang.StringToHost(loc.path + "/" + new, p1, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + new, p1, HostLang.pep383, err);
IF err = 0 THEN
res := stdio.rename(p0, p1);
IF res = 0 THEN loc.res := 0 (* no error *)
WITH loc0: Locator DO
WITH loc1: Locator DO
IF IsName(name0) & IsName(name1) THEN
- HostLang.StringToHost(loc0.path + "/" + name0, a0, FALSE, err);
+ HostLang.StringToHost(loc0.path + "/" + name0, a0, HostLang.pep383, err);
IF err = 0 THEN
err := macro.stat(a0, s0);
IF err = 0 THEN
- HostLang.StringToHost(loc1.path + "/" + name1, a1, FALSE, err);
+ HostLang.StringToHost(loc1.path + "/" + name1, a1, HostLang.pep383, err);
IF err = 0 THEN
err := macro.stat(a1, s1);
IF err = 0 THEN
BEGIN
ASSERT(loc # NIL, 20);
WITH loc: Locator DO
- HostLang.StringToHost(loc.path, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path, pathname, HostLang.pep383, err);
IF err = 0 THEN
p := dirent.opendir(pathname);
IF p # NIL THEN
ent := dirent.readdir(p);
WHILE ent # NIL DO
- HostLang.HostToString(ent.d_name, name, FALSE, err);
+ HostLang.HostToString(ent.d_name, name, HostLang.pep383, err);
IF err = 0 THEN
- HostLang.StringToHost(loc.path + "/" + name, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + name, pathname, HostLang.pep383, err);
IF err = 0 THEN
res := macro.stat(pathname, s);
IF (res = 0) & ~IsDir(s) THEN
END;
t.name := name$;
t.type := ""; (* ??? *)
- t.length := s.st_size;
+ t.length := S.VAL((*!!!*)INTEGER, s.st_size);
tm := time.localtime(s.st_mtim.tv_sec);
IF tm # NIL THEN
t.modified.year := tm.tm_year + 1900;
BEGIN
ASSERT(loc # NIL, 20);
WITH loc: Locator DO
- HostLang.StringToHost(loc.path, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path, pathname, HostLang.pep383, err);
IF err = 0 THEN
p := dirent.opendir(pathname);
IF p # NIL THEN
ent := dirent.readdir(p);
WHILE ent # NIL DO
- HostLang.HostToString(ent.d_name, name, FALSE, err);
+ HostLang.HostToString(ent.d_name, name, HostLang.pep383, err);
IF err = 0 THEN
- HostLang.StringToHost(loc.path + "/" + name, pathname, FALSE, err);
+ HostLang.StringToHost(loc.path + "/" + name, pathname, HostLang.pep383, err);
IF err = 0 THEN
res := macro.stat(pathname, s);
IF (res = 0) & IsDir(s) & (name # ".") & (name # "..") THEN