Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Work with files as binaries, and add convenience aliases

  • Loading branch information...
commit 8cd1e19b5011408a75fb41d9373540d7eb8957b4 1 parent 67ade68
Tony Arcieri authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/file.re
View
13 lib/file.re
@@ -8,7 +8,7 @@
# This interface is subject to change!
module File
def open(fn)
- IODevice(fn, [~read])
+ IODevice(fn, [~read,~binary])
def open(fn, modes)
IODevice(fn, modes)
@@ -27,6 +27,9 @@ module File
when (~error, reason)
throw reason
+ def rm(fn)
+ delete(fn)
+
def delete(fn)
case file::delete(fn.to_list())
when ~ok
@@ -34,6 +37,9 @@ module File
when (~error, reason)
throw reason
+ def cp(src, dest)
+ copy(src, dest)
+
def copy(src, dest)
case file::copy(src.to_list(), dest.to_list())
when (~ok, _)
@@ -41,6 +47,9 @@ module File
when (~error, reason)
throw reason
+ def mv(src, dest)
+ move(src, dest)
+
def move(src, dest)
case file::rename(src.to_list(), dest.to_list())
when ~ok
@@ -62,7 +71,7 @@ class IODevice
def read(num)
case file::read(@file, reia_erl::r2e(num))
when (~ok, data)
- data.to_string()
+ data
when ~eof
~eof
when (~error, reason)
Please sign in to comment.
Something went wrong with that request. Please try again.