more file:// URI truncation :D

This commit is contained in:
Fil Maj 2012-02-17 11:40:22 -08:00 committed by Joe Bowser
parent 770a257ed3
commit 42430d5d11

View File

@ -975,6 +975,10 @@ public class FileUtils extends Plugin {
*/ */
/**/ /**/
public long write(String filename, String data, int offset) throws FileNotFoundException, IOException { public long write(String filename, String data, int offset) throws FileNotFoundException, IOException {
if (filename.startsWith("file://")) {
filename = filename.substring(7);
}
boolean append = false; boolean append = false;
if (offset > 0) { if (offset > 0) {
this.truncateFile(filename, offset); this.truncateFile(filename, offset);
@ -1001,6 +1005,10 @@ public class FileUtils extends Plugin {
* @throws FileNotFoundException, IOException * @throws FileNotFoundException, IOException
*/ */
private long truncateFile(String filename, long size) throws FileNotFoundException, IOException { private long truncateFile(String filename, long size) throws FileNotFoundException, IOException {
if (filename.startsWith("file://")) {
filename = filename.substring(7);
}
RandomAccessFile raf = new RandomAccessFile(filename, "rw"); RandomAccessFile raf = new RandomAccessFile(filename, "rw");
if (raf.length() >= size) { if (raf.length() >= size) {