New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cp.over and mv.over like write.over #206

Closed
cvogt opened this Issue Aug 30, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@cvogt
Contributor

cvogt commented Aug 30, 2015

write.over lets you overwrite files. Would be nice to have the same for cp and mv. wdyt @lihaoyi ? I might add them if they fit in.

@cvogt

This comment has been minimized.

Contributor

cvogt commented Aug 30, 2015

Checked out the code, so it's really just a slim wrapper over nio. Wondering what's the best move here. Support passing through nio CopyOptions[1]? Or provide defs for the most common combinations like REPLACE_EXISTING?

Also, shouldn't mv use ATOMIC_MOVE by default?

[1] https://docs.oracle.com/javase/tutorial/essential/io/move.html

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Aug 30, 2015

Seems reasonable.

I did not know about atomic_move, it sounds like we should probably use it.

I don't really care how its internally implemented, but some kind of
helpers to keep stuff DRY would work. That might mean passing in flags

Checked out the code, so it's really just a slim wrapper over nio.
Wondering what's the best move here. Support passing through nio
CopyOptions[1]? Or provide defs for the most common combinations like
REPLACE_EXISTING?

Also, shouldn't mv use ATOMIC_MOVE by default?

[1] https://docs.oracle.com/javase/tutorial/essential/io/move.html


Reply to this email directly or view it on GitHub
#206 (comment).

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Sep 7, 2015

I just bumped into a use case for this; this needs to happen

haoyi-Ammonite@ ls! wd/'readme/'target/'scalatex | (p => cp(p, wd/p.last))
java.nio.file.FileAlreadyExistsException: /Users/haoyi/Dropbox (Personal)/Workspace/Ammonite/ColoredTraces.png
    sun.nio.fs.UnixCopyFile.copy(UnixCopyFile.java:551)
    sun.nio.fs.UnixFileSystemProvider.copy(UnixFileSystemProvider.java:253)
    java.nio.file.Files.copy(Files.java:1274)
    ammonite.ops.cp$.ammonite$ops$cp$$copyOne$1(FileOps.scala:159)
    ammonite.ops.cp$.apply(FileOps.scala:162)
    cmd3$$anonfun$1$$anonfun$apply$1.apply(Main.scala:127)
    cmd3$$anonfun$1$$anonfun$apply$1.apply(Main.scala:127)
    scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
    scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
    scala.collection.Iterator$class.foreach(Iterator.scala:742)
    scala.collection.AbstractIterator.foreach(Iterator.scala:1194)
    scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    ammonite.ops.LsSeq.foreach(FileOps.scala:198)
    scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
    ammonite.ops.LsSeq.map(FileOps.scala:198)
    ammonite.ops.FilterMapExt.$bar(Extensions.scala:63)
    cmd3$$anonfun$1.apply(Main.scala:127)
    cmd3$$anonfun$1.apply(Main.scala:126)
    cmd3$.<init>(Main.scala:128)
    cmd3$.<clinit>(Main.scala:-1)

@lihaoyi lihaoyi added the enhancement label Dec 1, 2015

@lihaoyi

This comment has been minimized.

Owner

lihaoyi commented Feb 18, 2016

This has happened in master

@lihaoyi lihaoyi closed this Feb 18, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment