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
|
@Override
|
||||||
public boolean isDirectory() {
|
public boolean isDirectory() {
|
||||||
try {
|
try {
|
||||||
AssetFileDescriptor descriptor = myApplication.getAssets().openFd(getPath());
|
InputStream stream = myApplication.getAssets().open(getPath());
|
||||||
if (descriptor == null) {
|
if (stream == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
descriptor.close();
|
stream.close();
|
||||||
return false;
|
return false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -199,17 +199,19 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
@Override
|
@Override
|
||||||
public boolean exists() {
|
public boolean exists() {
|
||||||
try {
|
try {
|
||||||
AssetFileDescriptor descriptor = myApplication.getAssets().openFd(getPath());
|
InputStream stream = myApplication.getAssets().open(getPath());
|
||||||
if (descriptor != null) {
|
if (stream != null) {
|
||||||
descriptor.close();
|
stream.close();
|
||||||
// file exists
|
// file exists
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String[] names = myApplication.getAssets().list(getPath());
|
String[] names = myApplication.getAssets().list(getPath());
|
||||||
if (names != null && names.length != 0) {
|
if (names != null && names.length != 0) {
|
||||||
|
// directory exists
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -220,6 +222,7 @@ public final class ZLAndroidLibrary extends ZLibrary {
|
||||||
@Override
|
@Override
|
||||||
public long size() {
|
public long size() {
|
||||||
try {
|
try {
|
||||||
|
// TODO: for some files (archives, crt) descriptor cannot be opened
|
||||||
AssetFileDescriptor descriptor = myApplication.getAssets().openFd(getPath());
|
AssetFileDescriptor descriptor = myApplication.getAssets().openFd(getPath());
|
||||||
if (descriptor == null) {
|
if (descriptor == null) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue