Skip to content

Commit 006fe76

Browse files
author
yanqizhou
committed
支持SQLITE3结尾的文件名
1 parent e34f7c9 commit 006fe76

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

DebugDatabase/DebugDatabaseManager.m

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,22 +227,35 @@ - (NSDictionary*)getAllDBPathsWithDirectories:(NSArray*)directories {
227227
NSMutableDictionary *paths = @{}.mutableCopy;
228228

229229
for (NSString *directory in directories) {
230-
NSArray *dirList = [[[NSFileManager defaultManager] subpathsAtPath:directory] pathsMatchingExtensions:@[@"sqlite",@"SQLITE",@"db",@"DB"]];
230+
NSArray *dirList = [[[NSFileManager defaultManager] subpathsAtPath:directory] pathsMatchingExtensions:[self databaseSuffixs]];
231231

232232
for (NSString *subPath in dirList) {
233-
if ([subPath hasSuffix:@"sqlite"] || [subPath hasSuffix:@"SQLITE"]|| [subPath hasSuffix:@"db"]|| [subPath hasSuffix:@"DB"]) {
234-
[paths setObject:[directory stringByAppendingPathComponent:subPath] forKey:subPath.lastPathComponent];
233+
if ([self checkDatabaseFile:subPath]) {
234+
[paths setObject:[directory stringByAppendingPathComponent:subPath] forKey:subPath.lastPathComponent];
235235
}
236236
}
237237

238-
if ([directory hasSuffix:@"sqlite"] || [directory hasSuffix:@"SQLITE"]|| [directory hasSuffix:@"db"]|| [directory hasSuffix:@"DB"]) {
238+
if ([self checkDatabaseFile:directory]) {
239239
[paths setObject:directory forKey:directory.lastPathComponent];
240240
}
241241
}
242242

243243
return paths;
244244
}
245245

246+
- (BOOL)checkDatabaseFile:(NSString*)fileName {
247+
for (NSString *suffix in [self databaseSuffixs]) {
248+
if ([fileName hasSuffix:suffix]) {
249+
return YES;
250+
}
251+
}
252+
return NO;
253+
}
254+
255+
- (NSArray*)databaseSuffixs {
256+
return @[@"sqlite", @"SQLITE", @"db", @"DB", @"sqlite3", @"SQLITE3"];
257+
}
258+
246259
- (NSString*)getTableNameFromQuery:(NSString*)query {
247260
NSArray *words = [query componentsSeparatedByString:@" "];
248261
NSString *operator = [[words firstObject] lowercaseString];

YYDebugDatabase.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'YYDebugDatabase'
11-
s.version = '2.0.4'
11+
s.version = '2.0.5'
1212
s.summary = 'easy way to process splite database'
1313

1414
s.homepage = 'https://y500.me'

0 commit comments

Comments
 (0)