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
Comments
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 |
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 Checked out the code, so it's really just a slim wrapper over nio. Also, shouldn't mv use ATOMIC_MOVE by default? [1] https://docs.oracle.com/javase/tutorial/essential/io/move.html — |
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)
|
This has happened in master |
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.
The text was updated successfully, but these errors were encountered: