about summary refs log tree commit diff stats
path: root/src/io/loader.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-12-18 22:24:31 +0100
committerbptato <nincsnevem662@gmail.com>2022-12-18 22:24:31 +0100
commitb1ad3a6950c76fc38593f46eb39d65a7dc1bfcec (patch)
tree9ebdbf192fd5221a048061b23f7664a0b9a3e962 /src/io/loader.nim
parentbfaf210d87e90016f8f2521657bd04686170aa43 (diff)
downloadchawan-b1ad3a6950c76fc38593f46eb39d65a7dc1bfcec.tar.gz
Add file browser
Diffstat (limited to 'src/io/loader.nim')
-rw-r--r--src/io/loader.nim26
1 files changed, 1 insertions, 25 deletions
diff --git a/src/io/loader.nim b/src/io/loader.nim
index 775cb78f..2c4245c8 100644
--- a/src/io/loader.nim
+++ b/src/io/loader.nim
@@ -21,6 +21,7 @@ when defined(posix):
 
 import bindings/curl
 import io/about
+import io/file
 import io/http
 import io/request
 import io/urlfilter
@@ -46,31 +47,6 @@ type
     cookiejar*: CookieJar
     referrerpolicy*: ReferrerPolicy
 
-proc loadFile(url: Url, ostream: Stream) =
-  when defined(windows) or defined(OS2) or defined(DOS):
-    let path = url.path.serialize_unicode_dos()
-  else:
-    let path = url.path.serialize_unicode()
-  let istream = newFileStream(path, fmRead)
-  if istream == nil:
-    ostream.swrite(-1) # error
-    ostream.flush()
-  else:
-    ostream.swrite(0)
-    ostream.swrite(200) # ok
-    ostream.swrite(newHeaderList())
-    while not istream.atEnd:
-      const bufferSize = 4096
-      var buffer {.noinit.}: array[bufferSize, char]
-      while true:
-        let n = readData(istream, addr buffer[0], bufferSize)
-        if n == 0:
-          break
-        ostream.writeData(addr buffer[0], n)
-        ostream.flush()
-        if n < bufferSize:
-          break
-
 proc loadResource(request: Request, ostream: Stream) =
   case request.url.scheme
   of "file":