Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
character, dimension(n_buff) :: buffer
open (newunit=u_r,file="src", action="read", form="unformatted", &
access="stream")
open(newunit=u_w,file="dst", action="write", form="unformatted",&
access="stream")
inquire(unit=u_r,size=sz)
do while (sz > 0)
n_chunk = min(sz, n_buff)
read (unit=u_r) buffer(1:n_chunk)
write (unit=u_w) buffer(1:n_chunk)
sz = sz - n_chunk
end do
func copy(dst, src string) error {
f, err := os.Open(src)
if err != nil {
return err
}
defer f.Close()
stat, err := f.Stat()
if err != nil {
return err
}
g, err := os.OpenFile(dst, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, stat.Mode())
if err != nil {
return err
}
defer g.Close()
_, err = io.Copy(g, f)
if err != nil {
return err
}
return os.Chmod(dst, stat.Mode())
}
new File(dst).bytes = new File(src).bytes
new File(src).withInputStream { input ->
new File(dst).withOutputStream {output ->
output << input
}
}