diff --git a/ueforth/Makefile b/ueforth/Makefile index bec0e6b..ba98143 100644 --- a/ueforth/Makefile +++ b/ueforth/Makefile @@ -120,7 +120,9 @@ POSIX_BOOT = common/boot.fs common/terminal.fs \ $(GEN)/posix_boot.h: common/source_to_string.js $(POSIX_BOOT) | $(GEN) echo "ok" | cat $(POSIX_BOOT) - | $< boot >$@ -WINDOWS_BOOT = common/boot.fs common/terminal.fs windows/windows.fs +WINDOWS_BOOT = common/boot.fs common/terminal.fs \ + windows/windows.fs \ + common/tasks.fs common/streams.fs common/blocks.fs $(GEN)/windows_boot.h: common/source_to_string.js $(WINDOWS_BOOT) | $(GEN) echo "ok" | cat $(WINDOWS_BOOT) - | $< boot >$@ diff --git a/ueforth/posix/posix.fs b/ueforth/posix/posix.fs index d0f0849..9d3dd4d 100644 --- a/ueforth/posix/posix.fs +++ b/ueforth/posix/posix.fs @@ -77,7 +77,6 @@ decimal ' posix-bye is bye ( I/O Error Helpers ) -: 0ior ( n -- n ior ) dup 0= if errno else 0 then ; : 0z -rot s>z swap rename sign-extend ; : read-file ( a n fh -- n ior ) -rot read 0r write r> = 0= ; -: file-position ( fh -- n ior ) dup 0 SEEK_CUR lseek 0r s>z r> FILE_SHARE_READ FILE_SHARE_WRITE or NULL + OPEN_EXISTING FILE_ATTRIBUTE_NORMAL NULL CreateFileA 0r s>z r> FILE_SHARE_READ FILE_SHARE_WRITE or NULL + CREATE_ALWAYS FILE_ATTRIBUTE_NORMAL NULL CreateFileA 0z DeleteFileA 0=ior ; +: rename-file ( a n a n -- ior ) s>z -rot s>z swap MoveFileA 0=ior ; +: read-file ( a n fh -- n ior ) -rot 0 >r rp@ NULL ReadFile r> swap 0= ior ; +: write-file ( a n fh -- ior ) + -rot dup >r 0 >r rp@ NULL WriteFile + if r> r> <> else rdrop rdrop GetLastError then ; +: file-position ( fh -- n ior ) + 0 NULL FILE_CURRENT SetFilePointer dup invalid?ior ; +: reposition-file ( n fh -- ior ) + swap NULL FILE_BEGIN SetFilePointer invalid?ior ; +: resize-file ( n fh -- ior ) + dup file-position dup if drop 2drop 1 ior exit else drop then >r + dup -rot reposition-file if rdrop drop 1 ior exit then + dup SetEndOfFile 0= if rdrop drop 1 ior exit then + r> swap reposition-file ; +: file-size ( fh -- n ior ) NULL GetFileSize dup invalid?ior ; + +( Other Utils ) +: ms ( n -- ) Sleep ;