|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
FileExtras.copyTo() appears to be brokenHi all,
I just attempted to copy a file using: import scalax.io.Implicits._ import java.io.File object App extends Application { new File("/Users/andrew/books.txt").copyTo(new File("/Users/andrew/ backup-books.txt")) } And get the following exception: Caused by: java.io.FileNotFoundException: /Users/andrew/backup- books.txt (No such file or directory) Note: it's complaining about the destination file not existing, not the source file. The problem appears to be that the copy method uses FileExtras.channel to copy the file. The channel created is always from a FileInputStream, but in the case of copy the destination should be a channel from a FileOutputStream. See: http://hg.scalaforge.org/scalax/general/file/05bdf43a3449/src/scalax/io/files.scala Maybe a new method, outChannel, should be added to get the channel from a FileOutputStream and copy changed to use it for the destination file. (And maybe channel should be renamed to inChannel for consistency) As an aside, what JVM is scalax supposed to be targetting? AFAIK, channels are JDK 1.5+ only. Cheers, Andrew Full stack trace follows. Caused by: java.io.FileNotFoundException: /Users/andrew/backup- books.txt (No such file or directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:106) at scalax.io.FileExtras$$anon$1.unsafeOpen(files.scala:52) at scalax.io.FileExtras$$anon$1.unsafeOpen(files.scala:49) at scalax.control.ManagedResource.acquireFor(resources.scala:70) at scalax.control.ManagedResource.foreach(resources.scala:64) at scalax.io.FileHelp$$anonfun$copy$1.apply(files.scala:132) at scalax.io.FileHelp$$anonfun$copy$1.apply(files.scala:131) at scalax.control.ManagedResource.acquireFor(resources.scala:72) at scalax.control.ManagedResource.foreach(resources.scala:64) at scalax.io.FileHelp$.copy(files.scala:131) at scalax.io.FileExtras.copyTo(files.scala:94) at bookworm.App$.<init>(App.scala:7) at bookworm.App$.<clinit>(App.scala) ... 10 more |
|
|
Re: FileExtras.copyTo() appears to be brokenOn 2008-04-18 17:01:09 Andrew O'Malley wrote:
> Hi all, > > I just attempted to copy a file using: > > import scalax.io.Implicits._ > import java.io.File > > object App extends Application { > new File("/Users/andrew/books.txt").copyTo(new > File("/Users/andrew/ backup-books.txt")) > } > > And get the following exception: > Caused by: java.io.FileNotFoundException: /Users/andrew/backup- > books.txt (No such file or directory) > > Note: it's complaining about the destination file not existing, not > the source file. > > The problem appears to be that the copy method uses > FileExtras.channel to copy the file. The channel created is always > from a FileInputStream, but in the case of copy the destination > should be a channel from a FileOutputStream. > > See: > http://hg.scalaforge.org/scalax/general/file/05bdf43a3449/src/scalax/io/files.scala > > Maybe a new method, outChannel, should be added to get the channel > from a FileOutputStream and copy changed to use it for the > destination file. (And maybe channel should be renamed to inChannel > for consistency) Fixed. Thanks for the report. > As an aside, what JVM is scalax supposed to be targetting? AFAIK, > channels are JDK 1.5+ only. Yes, we're targeting JVM 1.5. Cheers /J |
| Free embeddable forum powered by Nabble | Forum Help |