diff options
| author | Kai Gunger <kgunger12@gmail.com> | 2026-11-16 00:54:12 -0500 |
|---|---|---|
| committer | Kai Gunger <kgunger12@gmail.com> | 2026-11-16 00:54:12 -0500 |
| commit | 33c1bca9388f6c5501424bdd91a82b5819337c52 (patch) | |
| tree | 927f811b14554cb3a4672993c8f869ade2ca536c /io | |
| parent | bcc923602fbbcb50a35e7870aec6b26c96175c10 (diff) | |
fixes for file
Diffstat (limited to 'io')
| -rw-r--r-- | io/file.tnsl | 8 | ||||
| -rw-r--r-- | io/io.tnsl | 1 | ||||
| -rw-r--r-- | io/path.tnsl | 10 |
3 files changed, 13 insertions, 6 deletions
diff --git a/io/file.tnsl b/io/file.tnsl index 83e9d0d..5dffeaa 100644 --- a/io/file.tnsl +++ b/io/file.tnsl @@ -13,7 +13,6 @@ struct File { self.path.init(str) self.handle = -1 self.at_end = false - self.pos = 0 ;/ /; relative (~uint8 path) [File] @@ -41,6 +40,8 @@ struct File { /; if (self.handle + 1 == 0) self.at_end = true + ;; else + self.pos = 0 ;/ _delete(p) ;/ @@ -50,6 +51,8 @@ struct File { self.handle = _create_file(p) /; if (self.handle + 1 == 0) self.at_end = true + ;; else + self.pos = 0 ;/ _delete(p) ;/ @@ -57,8 +60,7 @@ struct File { /; close /; if (self.handle + 1 !== 0) _close_file(self.handle) - self.handle = 0 - self.handle-- + self.handle = -1 self.at_end = false ;/ ;/ @@ -1,5 +1,6 @@ /; module io import "file.tnsl" + import "path.tnsl" ;/ diff --git a/io/path.tnsl b/io/path.tnsl index 5a71403..13fc574 100644 --- a/io/path.tnsl +++ b/io/path.tnsl @@ -12,6 +12,9 @@ uint8 PATH_SEP = '/' self.strings.init(8) ~uint8 real = _realpath(path) + /; if (real == null) + return + ;/ box.List tmp tmp.init(1) @@ -45,13 +48,13 @@ uint8 PATH_SEP = '/' return out.as_cstr() ;/ - ~uint8 str = self.strings.get(0) - out.push_cstr(str) + ~~uint8 str = self.strings.get(0) + out.push_cstr(str`) /; loop (int i = 1; i < self.strings.count) [i++] str = self.strings.get(i) out.push(~PATH_SEP) - out.push_cstr(str) + out.push_cstr(str`) ;/ return out.as_cstr() @@ -88,6 +91,7 @@ uint8 PATH_SEP = '/' Path out out.init(full) + return out ;/ /; end |