NSMutableArray *themesOnDisk([NSMutableArray arrayWithCapacity:4]);
for (NSString *theme in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:@"/System/Library/LockCydgets" error:NULL])
if ([theme hasSuffix:@".cydget"])
- [themesOnDisk addObject:[theme stringByDeletingPathExtension]];
+ if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"/System/Library/LockCydgets/%@/Info.plist", theme]]) {
+ if (NSArray *version = [info objectForKey:@"CYVersionFilter"]) {
+ size_t count([version count]);
+ if (count == 0 || count > 2)
+ continue;
+
+ double lower([[version objectAtIndex:0] doubleValue]);
+ if (kCFCoreFoundationVersionNumber < lower)
+ continue;
+
+ if (count != 1) {
+ double upper([[version objectAtIndex:1] doubleValue]);
+ if (upper <= kCFCoreFoundationVersionNumber)
+ continue;
+ }
+ }
+
+ [themesOnDisk addObject:[theme stringByDeletingPathExtension]];
+ }
NSMutableSet *themesSet([NSMutableSet set]);