Author: rmottola
Date: Tue Nov 24 19:06:06 2015
New Revision: 39195
URL: http://svn.gna.org/viewcvs/gnustep?rev=39195&view=rev
Log:
Scan for Images and su-dirs explicitely and skip over all hidden directories,
instead of one big directory enumerator
Modified:
apps/thematic/trunk/ChangeLog
apps/thematic/trunk/ThemeDocument.m
Modified: apps/thematic/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/apps/thematic/trunk/ChangeLog?rev=39195&r1=39194&r2=39195&view=diff
==============================================================================
--- apps/thematic/trunk/ChangeLog (original)
+++ apps/thematic/trunk/ChangeLog Tue Nov 24 19:06:06 2015
@@ -1,3 +1,8 @@
+2015-11-24 Riccardo Mottola <[email protected]>
+
+ * ThemeDocument.m (applicationImageNames)
+ Scan for Images and su-dirs explicitely and skip over all hidden
directories, instead of one big directory enumerator.
+
2015-11-19 Riccardo Mottola <[email protected]>
* ImageElement.m
Modified: apps/thematic/trunk/ThemeDocument.m
URL:
http://svn.gna.org/viewcvs/gnustep/apps/thematic/trunk/ThemeDocument.m?rev=39195&r1=39194&r2=39195&view=diff
==============================================================================
--- apps/thematic/trunk/ThemeDocument.m (original)
+++ apps/thematic/trunk/ThemeDocument.m Tue Nov 24 19:06:06 2015
@@ -247,30 +247,60 @@
- (NSDictionary*) applicationImageNames
{
NSFileManager *mgr;
- NSString *path;
- NSDirectoryEnumerator *enumerator;
+ NSString *pathOfTI;
+ NSString *path1;
+ NSEnumerator *enumerator1;
NSMutableDictionary *images;
+ /*
+ We may have top-level images in ThemeImages. These are common images.
+ We may have then subdirectories with bundle identifieres.
+ We loop twice and scan only subdirectories.
+ We want to avoid hidden subdirs (like those created by version control
systems).
+ */
+
mgr = [NSFileManager defaultManager];
- path = [_rsrc stringByAppendingPathComponent: @"ThemeImages"];
- enumerator = [mgr enumeratorAtPath: path];
+ pathOfTI = [_rsrc stringByAppendingPathComponent: @"ThemeImages"];
+ enumerator1 = [[mgr directoryContentsAtPath: pathOfTI] objectEnumerator];
images = [NSMutableDictionary dictionary];
- while ((path = [enumerator nextObject]) != nil)
- {
- NSString *file = [path lastPathComponent];
-
- if (NO == [file isEqual: path])
- {
- NSString *identifier;
- NSMutableArray *array;
-
- identifier = [path stringByDeletingLastPathComponent];
- if (nil == (array = [images objectForKey: identifier]))
+
+ while ((path1 = [enumerator1 nextObject]) != nil)
+ {
+ BOOL isDir1;
+ NSString *fileOrDir1;
+
+
+ fileOrDir1 = [pathOfTI stringByAppendingPathComponent:path1];
+ if (![path1 hasPrefix:@"."])
+ {
+ if ([mgr fileExistsAtPath:fileOrDir1 isDirectory:&isDir1] && isDir1)
{
+ NSString *path2;
+ NSEnumerator *enumerator2;
+ NSMutableArray *array;
+
array = [NSMutableArray array];
- [images setObject: array forKey: identifier];
+ [images setObject: array forKey:path1];
+ enumerator2 = [[mgr directoryContentsAtPath: fileOrDir1]
objectEnumerator];
+ while ((path2 = [enumerator2 nextObject]) != nil)
+ {
+ BOOL isDir2;
+ NSString *fileOrDir2;
+
+ fileOrDir2 = [fileOrDir1
stringByAppendingPathComponent:path2];
+ if (![path2 hasPrefix:@"."])
+ {
+ if ([mgr fileExistsAtPath:fileOrDir2
isDirectory:&isDir2] && !isDir2)
+ {
+ [array addObject: path2];
+ }
+ }
+ }
}
- [array addObject: file];
+ else
+ {
+ // Here we would have images in the root (common)
+ }
}
}
return images;
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs