refine exception process
This commit is contained in:
parent
581aaf74f7
commit
7fd0ad99ac
|
|
@ -1,40 +1,44 @@
|
||||||
package com.storm.wind.xpatch.task;
|
package com.storm.wind.xpatch.task;
|
||||||
|
|
||||||
import com.storm.wind.xpatch.util.FileUtils;
|
import com.storm.wind.xpatch.util.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by xiawanli on 2019/4/6
|
* Created by xiawanli on 2019/4/6
|
||||||
*/
|
*/
|
||||||
public class SaveOriginalApplicationNameTask implements Runnable {
|
public class SaveOriginalApplicationNameTask implements Runnable {
|
||||||
|
|
||||||
private final String applcationName;
|
private final String applcationName;
|
||||||
private final String unzipApkFilePath;
|
private final String unzipApkFilePath;
|
||||||
private String dstFilePath;
|
private String dstFilePath;
|
||||||
|
|
||||||
private final String APPLICATION_NAME_ASSET_PATH = "assets/xpatch_asset/original_application_name.ini";
|
private final String APPLICATION_NAME_ASSET_PATH = "assets/xpatch_asset/original_application_name.ini";
|
||||||
|
|
||||||
public SaveOriginalApplicationNameTask(String applicationName, String unzipApkFilePath) {
|
public SaveOriginalApplicationNameTask(String applicationName, String unzipApkFilePath) {
|
||||||
this.applcationName = applicationName;
|
this.applcationName = applicationName;
|
||||||
this.unzipApkFilePath = unzipApkFilePath;
|
this.unzipApkFilePath = unzipApkFilePath;
|
||||||
|
|
||||||
this.dstFilePath = (unzipApkFilePath + APPLICATION_NAME_ASSET_PATH).replace("/", File.separator);
|
this.dstFilePath = (unzipApkFilePath + APPLICATION_NAME_ASSET_PATH).replace("/", File.separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ensureDstFileCreated();
|
ensureDstFileCreated();
|
||||||
FileUtils.writeFile(dstFilePath, applcationName);
|
FileUtils.writeFile(dstFilePath, applcationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureDstFileCreated() {
|
private void ensureDstFileCreated() {
|
||||||
File dstParentFile = new File(dstFilePath);
|
File dstParentFile = new File(dstFilePath);
|
||||||
if (!dstParentFile.getParentFile().getParentFile().exists()) {
|
if (!dstParentFile.getParentFile().getParentFile().exists()) {
|
||||||
dstParentFile.getParentFile().getParentFile().mkdirs();
|
if(!dstParentFile.getParentFile().getParentFile().mkdirs()){
|
||||||
}
|
throw new IllegalStateException("mkdir fail");
|
||||||
if (!dstParentFile.getParentFile().exists()) {
|
}
|
||||||
dstParentFile.getParentFile().mkdirs();
|
}
|
||||||
}
|
if (!dstParentFile.getParentFile().exists()) {
|
||||||
}
|
if(!dstParentFile.getParentFile().mkdirs()){
|
||||||
|
throw new IllegalStateException("mkdir fail");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue