Permalink
Browse files

Work with files as binaries, and add convenience aliases

  • Loading branch information...
1 parent 67ade68 commit 8cd1e19b5011408a75fb41d9373540d7eb8957b4 Tony Arcieri committed Jan 27, 2009
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/file.re
View
@@ -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,20 +27,29 @@ module File
when (~error, reason)
throw reason
+ def rm(fn)
+ delete(fn)
+
def delete(fn)
case file::delete(fn.to_list())
when ~ok
~ok
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, _)
~ok
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)

0 comments on commit 8cd1e19

Please sign in to comment.