summaryrefslogtreecommitdiff
path: root/io
diff options
context:
space:
mode:
Diffstat (limited to 'io')
-rw-r--r--io/file.tnsl8
-rw-r--r--io/io.tnsl1
-rw-r--r--io/path.tnsl10
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
;/
;/
diff --git a/io/io.tnsl b/io/io.tnsl
index 5baead5..3364490 100644
--- a/io/io.tnsl
+++ b/io/io.tnsl
@@ -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