mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
litres authentication has been fixed: corrected exists() method for asset-based files
This commit is contained in:
parent
53856e9fc3
commit
fa57c3720e
1 changed files with 9 additions and 6 deletions
|
@ -185,11 +185,11 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
|||
@Override
|
||||
public boolean isDirectory() {
|
||||
try {
|
||||
AssetFileDescriptor descriptor = myApplication.getAssets().openFd(getPath());
|
||||
if (descriptor == null) {
|
||||
InputStream stream = myApplication.getAssets().open(getPath());
|
||||
if (stream == null) {
|
||||
return true;
|
||||
}
|
||||
descriptor.close();
|
||||
stream.close();
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
return true;
|
||||
|
@ -199,17 +199,19 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
|||
@Override
|
||||
public boolean exists() {
|
||||
try {
|
||||
AssetFileDescriptor descriptor = myApplication.getAssets().openFd(getPath());
|
||||
if (descriptor != null) {
|
||||
descriptor.close();
|
||||
InputStream stream = myApplication.getAssets().open(getPath());
|
||||
if (stream != null) {
|
||||
stream.close();
|
||||
// file exists
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
String[] names = myApplication.getAssets().list(getPath());
|
||||
if (names != null && names.length != 0) {
|
||||
// directory exists
|
||||
return true;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -220,6 +222,7 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
|||
@Override
|
||||
public long size() {
|
||||
try {
|
||||
// TODO: for some files (archives, crt) descriptor cannot be opened
|
||||
AssetFileDescriptor descriptor = myApplication.getAssets().openFd(getPath());
|
||||
if (descriptor == null) {
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue