diff --git a/src/brut/androlib/ApkDecoder.java b/src/brut/androlib/ApkDecoder.java index 3f1f0388..168b6bdc 100644 --- a/src/brut/androlib/ApkDecoder.java +++ b/src/brut/androlib/ApkDecoder.java @@ -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; } diff --git a/src/brut/androlib/OutDirExistsException.java b/src/brut/androlib/OutDirExistsException.java new file mode 100644 index 00000000..ca9389e2 --- /dev/null +++ b/src/brut/androlib/OutDirExistsException.java @@ -0,0 +1,38 @@ +/* + * Copyright 2010 Ryszard Wiśniewski . + * + * 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 + */ +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() { + } +}