Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
neobenedict committed Feb 19, 2024
1 parent c1da955 commit 7d62604
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions nextgenfs/src/main/java/io/rayshift/translatefgo/NGFSService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.rayshift.translatefgo;

import android.os.Build;
import android.os.FileUtils;
import android.os.RemoteException;
import android.system.Os;
Expand All @@ -15,6 +16,7 @@
import java.io.RandomAccessFile;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -64,8 +66,15 @@ public boolean RemoveFileIfExists(String filename, NGFSError error) throws Remot
File file = new File(filename);
try {
error.IsSuccess = true;
Files.deleteIfExists(file.toPath());
return true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Files.deleteIfExists(file.toPath());
return true;
}
else {
error.IsSuccess = false;
error.Error = "Android version too low.";
return false;
}
}
catch (Exception ex) {
error.IsSuccess = false;
Expand All @@ -78,7 +87,14 @@ public boolean RemoveFileIfExists(String filename, NGFSError error) throws Remot
public boolean GetFileExists(String filename, NGFSError error) throws RemoteException {
File file = new File(filename);
error.IsSuccess = true;
return Files.exists(file.toPath());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return Files.exists(file.toPath());
}
else {
error.IsSuccess = false;
error.Error = "Android version too low.";
return false;
}
}

@Override
Expand Down Expand Up @@ -135,9 +151,17 @@ public boolean CopyFile(String source, String destination, NGFSError error) thro
try {
File input = new File(source);
File output = new File(destination);
Files.copy(input.toPath(), output.toPath());
error.IsSuccess = true;
return true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
Files.copy(input.toPath(), output.toPath(), StandardCopyOption.REPLACE_EXISTING);

error.IsSuccess = true;
return true;
}
else {
error.IsSuccess = false;
error.Error = "Android version too low.";
return false;
}
}
catch (Exception ex) {
error.IsSuccess = false;
Expand Down

0 comments on commit 7d62604

Please sign in to comment.