Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
Add check for datapath creation
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtheis committed May 30, 2015
1 parent 01d01ba commit 4693614
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions tess-two/src/com/googlecode/tesseract/android/TessBaseAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,7 @@ protected void finalize() throws Throwable {
* @return <code>true</code> on success
*/
public boolean init(String datapath, String language) {
if (datapath == null)
throw new IllegalArgumentException("Data path must not be null!");
if (!datapath.endsWith(File.separator))
datapath += File.separator;

File tessdata = new File(datapath + "tessdata");
if (!tessdata.exists() || !tessdata.isDirectory())
throw new IllegalArgumentException("Data path must contain subfolder tessdata!");

return nativeInit(datapath, language);
return init(datapath, language, OEM_DEFAULT);
}

/**
Expand All @@ -301,6 +292,10 @@ public boolean init(String datapath, String language, int ocrEngineMode) {
if (!datapath.endsWith(File.separator))
datapath += File.separator;

File datapathFile = new File(datapath);
if (!datapathFile.exists())
throw new IllegalArgumentException("Data path does not exist!");

File tessdata = new File(datapath + "tessdata");
if (!tessdata.exists() || !tessdata.isDirectory())
throw new IllegalArgumentException("Data path must contain subfolder tessdata!");
Expand Down

0 comments on commit 4693614

Please sign in to comment.