summaryrefslogtreecommitdiff
path: root/tnslc/utils/file.tnsl
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-03-30 04:15:10 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-03-30 04:15:10 -0400
commitbb7bbcc03386089dce1353e98c071c15c45aa82f (patch)
tree2d0872fb998bddf93e040d3e38051dbef039443d /tnslc/utils/file.tnsl
parent59aabd4ed77ff3ede1df368ad134c56a6f8787c0 (diff)
copy file example
Diffstat (limited to 'tnslc/utils/file.tnsl')
-rw-r--r--tnslc/utils/file.tnsl17
1 files changed, 14 insertions, 3 deletions
diff --git a/tnslc/utils/file.tnsl b/tnslc/utils/file.tnsl
index a33e30c..978f31b 100644
--- a/tnslc/utils/file.tnsl
+++ b/tnslc/utils/file.tnsl
@@ -5,7 +5,6 @@ struct File {
}
~uint8 PT_HANDLE = "Handle: %p\n\0"
-uint INVALID_HANDLE = 0xffffffff
~uint8 PARENT_DIR = ".."
~uint8 CURRENT_DIR = "."
@@ -43,7 +42,7 @@ uint INVALID_HANDLE = 0xffffffff
/; end
self.path.end()
- /; if (self.handle < INVALID_HANDLE && self.handle != NULL)
+ /; if (self.handle + 1 !== 0)
_close_file(self.handle)
self.handle = NULL
;/
@@ -52,17 +51,23 @@ uint INVALID_HANDLE = 0xffffffff
/; open
~uint8 p = self.path.to_cstr('/')
self.handle = _open_file(p)
+ /; if (self.handle + 1 == 0)
+ self.at_end = true
+ ;/
_delete(p)
;/
/; create
~uint8 p = self.path.to_cstr('/')
self.handle = _create_file(p)
+ /; if (self.handle + 1 == 0)
+ self.at_end = true
+ ;/
_delete(p)
;/
/; close
- /; if (self.handle !== INVALID_HANDLE && self.handle !== NULL)
+ /; if (self.handle + 1 !== 0)
_close_file(self.handle)
self.handle = NULL
self.at_end = false
@@ -86,4 +91,10 @@ uint INVALID_HANDLE = 0xffffffff
;/
;/
+ /; write_cstr (~uint8 str)
+ /; loop (self.at_end == false && str` !== 0) [str++]
+ self.write(str`)
+ ;/
+ ;/
+
;/