2 docSlot("with(aPath)", "Returns a new instance with the provided path.")
3 with
:= method(path
, self clone setPath(path
))
5 newSlot("streamDestination")
6 newSlot("streamReadSize", 1024*64)
7 startStreaming
:= method(streamTo(streamDestination
))
9 streamTo
:= method(streamDestination
,
14 readToBufferLength(b
, streamReadSize
)
15 streamDestination
write(b
)
20 copyToPath
:= method(dstPath
,
21 dst
:= File with(dstPath
) open
22 self open
streamTo(dst
)
27 lockFile
:= method(File clone setPath(path
.. ".lock"))
29 lock
:= method(timeout
,
30 if(timeout
== nil
, timeout
= 10)
34 while(lockFile exists
,
36 waited
= waited
+ waitTime
37 if(waited
> timeout
, Exception raise("unable to acquire lock on " .. path
))
42 unlock
:= method(lockFile remove
)
44 setContents
:= method(d
, self open
write(d
) close
)
48 docSlot("asFile", "Returns a new File object with the receiver as it's path.")