Skip to content

Commit 32e9a5d

Browse files
committed
fix os x support
1 parent d607202 commit 32e9a5d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

LKDBHelper/Helper/LKDBHelper.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,16 @@ - (void)setDBPath:(NSString *)filePath
166166
NSString *dirPath = [filePath substringToIndex:lastComponent.location];
167167
BOOL isDir = NO;
168168
BOOL isCreated = [fileManager fileExistsAtPath:dirPath isDirectory:&isDir];
169-
169+
170170
if ((isCreated == NO) || (isDir == NO)) {
171171
NSError *error = nil;
172+
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
173+
NSDictionary* attributes = @{NSFileProtectionKey:NSFileProtectionNone};
174+
#else
175+
NSDictionary* attributes = nil;
176+
#endif
172177
BOOL success = [fileManager createDirectoryAtPath:dirPath withIntermediateDirectories:YES
173-
attributes:@{NSFileProtectionKey:NSFileProtectionNone} error:&error];
178+
attributes:attributes error:&error];
174179

175180
if (success == NO) {
176181
LKErrorLog(@"create dir error: %@", error.debugDescription);
@@ -182,7 +187,9 @@ - (void)setDBPath:(NSString *)filePath
182187
* @brief Disk I/O error when device is locked
183188
* https://github.com/ccgus/fmdb/issues/262
184189
*/
190+
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
185191
[fileManager setAttributes:@{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:dirPath error:nil];
192+
#endif
186193
}
187194
}
188195

@@ -195,11 +202,12 @@ - (void)setDBPath:(NSString *)filePath
195202

196203
self.bindingQueue = [[FMDatabaseQueue alloc]initWithPath:filePath
197204
flags:SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FILEPROTECTION_NONE];
198-
205+
#ifdef __IPHONE_OS_VERSION_MIN_REQUIRED
199206
if([fileManager fileExistsAtPath:filePath])
200207
{
201208
[fileManager setAttributes:@{NSFileProtectionKey:NSFileProtectionNone} ofItemAtPath:filePath error:nil];
202209
}
210+
#endif
203211

204212
_encryptionKey = nil;
205213

0 commit comments

Comments
 (0)