Throwing exception when decoding to existing directory.

This commit is contained in:
Ryszard Wiśniewski 2010-06-01 14:30:08 +02:00
parent 25ec196cfa
commit 43797e0c0d
2 changed files with 48 additions and 0 deletions

View File

@ -56,6 +56,11 @@ public class ApkDecoder {
public void decode() throws AndrolibException {
File outDir = getOutDir();
if (! mForceDelete && outDir.exists()) {
throw new OutDirExistsException();
}
try {
OS.rmdir(outDir);
} catch (BrutException ex) {
@ -116,6 +121,10 @@ public class ApkDecoder {
mDebug = debug;
}
public void setForceDelete(boolean forceDelete) {
mForceDelete = forceDelete;
}
public ResTable getResTable() throws AndrolibException {
if (mResTable == null) {
mResTable = mAndrolib.getResTable(mApkFile);
@ -147,4 +156,5 @@ public class ApkDecoder {
private short mDecodeSources = DECODE_SOURCES_SMALI;
private short mDecodeResources = DECODE_RESOURCES_FULL;
private boolean mDebug = false;
private boolean mForceDelete = false;
}

View File

@ -0,0 +1,38 @@
/*
* Copyright 2010 Ryszard Wiśniewski <brut.alll@gmail.com>.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* under the License.
*/
package brut.androlib;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public class OutDirExistsException extends AndrolibException {
public OutDirExistsException(Throwable cause) {
super(cause);
}
public OutDirExistsException(String message, Throwable cause) {
super(message, cause);
}
public OutDirExistsException(String message) {
super(message);
}
public OutDirExistsException() {
}
}