Commit 4cb4a1dd authored by fallenstardust's avatar fallenstardust

支持读取ypk文件

parent 8ca9e64e
......@@ -1300,11 +1300,11 @@ void Game::LoadExpansions() {
return;
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".zip") != 0)
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".zip") != 0 ||strcasecmp(dirp->d_name + len - 4, ".ypk") != 0)
continue;
char upath[1024];
sprintf(upath, "./expansions/%s", dirp->d_name);
dataManager.FileSystem->addFileArchive(upath, true, false);
dataManager.FileSystem->addFileArchive(upath, true, false, EFAT_ZIP);
}
closedir(dir);
#endif
......
......@@ -257,6 +257,17 @@ public class AppsSettings {
pathList.add(file.getAbsolutePath());
}
}
File[] ypks = expansionsDir.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.isFile() && file.getName().toLowerCase(Locale.US).endsWith(".ypk");
}
});
if (ypks != null) {
for (File file : ypks) {
pathList.add(file.getAbsolutePath());
}
}
}
}
}
......
......@@ -227,7 +227,7 @@ public class ImageLoader implements Closeable {
File[] files = new File(AppsSettings.get().getResourcePath(), Constants.CORE_EXPANSIONS).listFiles();
if (files != null) {
for (File file :files) {
if (file.isFile() && file.getName().endsWith(".zip")) {
if (file.isFile() && (file.getName().endsWith(".zip") || file.getName().endsWith(".ypk"))) {
ZipEntry entry = null;
InputStream inputStream = null;
ByteArrayOutputStream outputStream = null;
......
......@@ -96,7 +96,7 @@ public class DeckUtil {
}
files = appsSettings.getExpansionsPath().listFiles();
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".zip")) {
if (file.isFile() && (file.getName().endsWith(".zip") || file.getName().endsWith(".ypk"))) {
ZipFile zipFile = new ZipFile(file.getAbsoluteFile());
Enumeration entries = zipFile.entries();
while (entries.hasMoreElements()) {
......
......@@ -135,7 +135,7 @@ public class CardManager {
@Override
public boolean accept(File dir, String name) {
File file = new File(dir, name);
return file.isFile() && (name.endsWith(".cdb") || name.endsWith(".zip"));
return file.isFile() && ((name.endsWith(".cdb") || (name.endsWith(".zip") || name.endsWith(".ypk"))));
}
});
//读取全部卡片
......@@ -143,7 +143,7 @@ public class CardManager {
for (File file : files) {
if (file.getName().endsWith(".cdb")) {
count = readAllCards(file, cardDataHashMap);
} else if (file.getName().endsWith(".zip")) {
} else if (file.getName().endsWith(".zip") || file.getName().endsWith(".ypk")) {
Log.e("CardManager", "读取压缩包");
try {
for (File file1 : readZipCdb(file.getAbsolutePath())) {
......
package ocgcore;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import java.io.BufferedReader;
......@@ -52,7 +53,8 @@ public class StringManager implements Closeable {
File[] files = AppsSettings.get().getExpansionsPath().listFiles();
if (files != null) {
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".zip")) {
if (file.isFile() && (file.getName().endsWith(".zip") || file.getName().endsWith(".ypk"))) {
Log.e("StringManager", "读取压缩包");
try {
ZipFile zipFile = new ZipFile(file.getAbsoluteFile());
ZipEntry entry = zipFile.getEntry(Constants.CORE_STRING_PATH);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment