mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-07 23:03:11 +08:00
more file:// URI truncation :D
This commit is contained in:
parent
770a257ed3
commit
42430d5d11
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user