Skip to content

Commit 0e4b705

Browse files
author
Kirill Makankov
committed
1. documentsPath is renamed to cachesPath
2. Fixed some unnecessary logs in unit tests. 3. removed assertion on documetsPath
1 parent 72b4d2b commit 0e4b705

File tree

6 files changed

+38
-13
lines changed

6 files changed

+38
-13
lines changed
-500 Bytes
Binary file not shown.

TesseractOCR/G8Tesseract.mm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ - (id)initWithLanguage:(NSString *)language
103103

104104
if (_absoluteDataPath != nil) {
105105
// config Tesseract to search trainedData in tessdata folder of the Documents folder];
106-
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
107-
NSString *documentPath = documentPaths.firstObject;
108-
assert(documentPath);
109-
_absoluteDataPath = [documentPath stringByAppendingPathComponent:_absoluteDataPath].copy;
106+
NSArray *cachesPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
107+
NSString *cachesPath = cachesPaths.firstObject;
108+
109+
_absoluteDataPath = [cachesPath stringByAppendingPathComponent:_absoluteDataPath].copy;
110110

111111
[self moveTessdataToDocumentsDirectoryIfNecessary];
112112
}
@@ -227,7 +227,9 @@ - (BOOL)moveTessdataToDocumentsDirectoryIfNecessary
227227

228228
// delete broken symlinks first
229229
[fileManager removeItemAtPath:destinationFileName error:&error];
230+
230231
// than recreate it
232+
error = nil; // don't care about previous error, that can heppens if we tried to remove an symlink, which doesn't exist
231233
[fileManager createSymbolicLinkAtPath:destinationFileName
232234
withDestinationPath:filePath
233235
error:&error];

TestsProject/TestsProject.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
41C68DB31A41849100848AE1 /* image_sample.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 41C68DB21A41849100848AE1 /* image_sample.jpg */; };
2828
41C68DB51A41854600848AE1 /* image_sample_tr.png in Resources */ = {isa = PBXBuildFile; fileRef = 41C68DB41A41854600848AE1 /* image_sample_tr.png */; };
2929
732C54761A514DA6000322DA /* InitializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 732C54751A514DA5000322DA /* InitializationTests.m */; };
30+
732C54791A5288CC000322DA /* Defaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 732C54781A5288CC000322DA /* Defaults.m */; };
3031
8FA2F9CE23919BEC8C64A5EA /* libPods-TestsProjectTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5CD3C116A45C293ADAC81D1B /* libPods-TestsProjectTests.a */; };
3132
/* End PBXBuildFile section */
3233

@@ -72,6 +73,8 @@
7273
41C68DB41A41854600848AE1 /* image_sample_tr.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = image_sample_tr.png; sourceTree = "<group>"; };
7374
5CD3C116A45C293ADAC81D1B /* libPods-TestsProjectTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-TestsProjectTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
7475
732C54751A514DA5000322DA /* InitializationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InitializationTests.m; sourceTree = "<group>"; };
76+
732C54771A5288CC000322DA /* Defaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Defaults.h; sourceTree = "<group>"; };
77+
732C54781A5288CC000322DA /* Defaults.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Defaults.m; sourceTree = "<group>"; };
7578
/* End PBXFileReference section */
7679

7780
/* Begin PBXFrameworksBuildPhase section */
@@ -149,6 +152,8 @@
149152
732C54751A514DA5000322DA /* InitializationTests.m */,
150153
4115B97A1A3EF8E90004EC0A /* RecognitionTests.m */,
151154
4115B9781A3EF8E90004EC0A /* Supporting Files */,
155+
732C54771A5288CC000322DA /* Defaults.h */,
156+
732C54781A5288CC000322DA /* Defaults.m */,
152157
);
153158
path = TestsProjectTests;
154159
sourceTree = "<group>";
@@ -349,6 +354,7 @@
349354
isa = PBXSourcesBuildPhase;
350355
buildActionMask = 2147483647;
351356
files = (
357+
732C54791A5288CC000322DA /* Defaults.m in Sources */,
352358
414121231A4C5A5700583ED4 /* G8RecognitionTestsHelper.m in Sources */,
353359
4115B97B1A3EF8E90004EC0A /* RecognitionTests.m in Sources */,
354360
732C54761A514DA6000322DA /* InitializationTests.m in Sources */,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//
2+
// Defaults.h
3+
// TestsProject
4+
//
5+
// Created by ws233 on 30.12.14.
6+
// Copyright (c) 2014 Daniele Galiotto - www.g8production.com. All rights reserved.
7+
//
8+
9+
extern NSString *const kG8Languages;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// Defaults.m
3+
// TestsProject
4+
//
5+
// Created by ws233 on 30.12.14.
6+
// Copyright (c) 2014 Daniele Galiotto - www.g8production.com. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
NSString *const kG8Languages = @"eng";

TestsProject/TestsProjectTests/InitializationTests.m

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
//
2-
// RecognitionTests.m
2+
// InitializationTests.m
33
// TestsProjectTests
44
//
5-
// Created by Nikolay Volosatov on 15.12.14.
5+
// Created by ws233 on 29.12.14.
66
// Copyright (c) 2014 Daniele Galiotto - www.g8production.com.
77
// All rights reserved.
88
//
99

1010
#import <UIKit/UIKit.h>
1111
#import <TesseractOCR/TesseractOCR.h>
1212
#import <Kiwi/Kiwi.h>
13-
14-
#import "UIImage+G8Equal.h"
15-
16-
static NSString *const kG8Languages = @"eng";
13+
#import "Defaults.h"
1714

1815
SPEC_BEGIN(TesseractInitialization)
1916

@@ -33,9 +30,9 @@
3330
});
3431

3532
let(cashesPath, ^id{
36-
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
37-
NSString *documentPath = documentPaths.firstObject;
38-
return documentPath;
33+
NSArray *cachesPaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
34+
NSString *cachesPath = cachesPaths.firstObject;
35+
return cachesPath;
3936
});
4037

4138
context(@"not nil dataPath", ^{

0 commit comments

Comments
 (0)