minor: input file might not exist.

This commit is contained in:
adrian 2011-04-24 04:03:53 -04:00 committed by Ryszard Wiśniewski
parent 74ecd31a4d
commit 253a95c98d
3 changed files with 51 additions and 0 deletions

View File

@ -18,6 +18,7 @@ package brut.apktool;
import brut.androlib.*;
import brut.androlib.err.CantFindFrameworkResException;
import brut.androlib.err.InFileNotFoundException;
import brut.androlib.err.OutDirExistsException;
import java.io.File;
import java.io.IOException;
@ -122,6 +123,11 @@ public class Main {
"Destination directory (" + outDir.getAbsolutePath() + ") " +
"already exists. Use -f switch if you want to overwrite it.");
System.exit(1);
} catch (InFileNotFoundException ex) {
System.out.println(
"Input file (" + args[i] + ") " +
"was not found or was not readable.");
System.exit(1);
} catch (CantFindFrameworkResException ex) {
System.out.println(
"Can't find framework resources for package of id: " +

View File

@ -16,6 +16,7 @@
package brut.androlib;
import brut.androlib.err.InFileNotFoundException;
import brut.androlib.err.OutDirExistsException;
import brut.androlib.res.AndrolibResources;
import brut.androlib.res.data.ResPackage;
@ -64,6 +65,10 @@ public class ApkDecoder {
throw new OutDirExistsException();
}
if (! mApkFile.isFile() || ! mApkFile.canRead() ) {
throw new InFileNotFoundException();
}
try {
OS.rmdir(outDir);
} catch (BrutException ex) {

View File

@ -0,0 +1,40 @@
/**
* Copyright 2011 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.
*/
package brut.androlib.err;
import brut.androlib.AndrolibException;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public class InFileNotFoundException extends AndrolibException {
public InFileNotFoundException(Throwable cause) {
super(cause);
}
public InFileNotFoundException(String message, Throwable cause) {
super(message, cause);
}
public InFileNotFoundException(String message) {
super(message);
}
public InFileNotFoundException() {
}
}