1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 19:42:17 +02:00

fixed: impossible to access archive inside assets

This commit is contained in:
Nikolay Pultsin 2010-11-08 19:43:33 +00:00
parent 73e8aa1bce
commit eadd934695
21 changed files with 30 additions and 9 deletions

Binary file not shown.

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

@ -42,7 +42,7 @@ public abstract class ZLResourceFile extends ZLFile {
}
public String getNameWithExtension() {
return myPath;
return myPath.substring(myPath.lastIndexOf('/') + 1);
}
public ZLFile getParent() {

View file

@ -55,6 +55,6 @@ public abstract class ZLLanguageList {
}
public static ZLFile patternsFile() {
return ZLResourceFile.createResourceFile("languagePatterns.tar");
return ZLResourceFile.createResourceFile("languagePatterns");
}
}

View file

@ -20,7 +20,7 @@
package org.geometerplus.zlibrary.ui.android.library;
import java.io.*;
import java.util.Date;
import java.util.*;
import android.app.Application;
import android.content.res.Resources;
@ -31,6 +31,7 @@ import android.text.format.DateFormat;
import android.util.DisplayMetrics;
import org.geometerplus.zlibrary.core.library.ZLibrary;
import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile;
import org.geometerplus.zlibrary.core.network.ZLNetworkException;
import org.geometerplus.zlibrary.core.image.ZLImage;
@ -87,7 +88,6 @@ public final class ZLAndroidLibrary extends ZLibrary {
intent.putExtra(BookDownloaderService.SHOW_NOTIFICATIONS_KEY, BookDownloaderService.Notifications.ALL);
externalUrl = false;
}
// FIXME: initialize network library and use rewriteUrl!!!
final NetworkLibrary nLibrary = NetworkLibrary.Instance();
try {
nLibrary.initialize();
@ -149,19 +149,40 @@ public final class ZLAndroidLibrary extends ZLibrary {
}
@Override
public boolean exists() {
protected List<ZLFile> directoryEntries() {
try {
String[] names = myApplication.getAssets().list(getPath());
if (names != null && names.length != 0) {
ArrayList<ZLFile> files = new ArrayList<ZLFile>(names.length);
for (String n : names) {
files.add(new AndroidAssetsFile(getPath() + "/" + n));
}
return files;
}
} catch (IOException e) {
}
return Collections.emptyList();
}
@Override
public boolean isDirectory() {
try {
AssetFileDescriptor descriptor = myApplication.getAssets().openFd(getPath());
if (descriptor == null) {
return false;
return true;
}
descriptor.close();
return true;
} catch (IOException e) {
return false;
} catch (IOException e) {
return true;
}
}
@Override
public boolean exists() {
return true;
}
@Override
public long size() {
try {