| 1 |
/* |
| 2 |
Copyright (C) 2018, 2019, 2020, 2021 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
Written by: Gregory John Casamento <[email protected]> |
| 5 |
Date: 2024 November |
| 6 |
|
| 7 |
This file is part of the GNUstep XCode Library |
| 8 |
|
| 9 |
This library is free software; you can redistribute it and/or |
| 10 |
modify it under the terms of the GNU Lesser General Public |
| 11 |
License as published by the Free Software Foundation; either |
| 12 |
version 2 of the License, or (at your option) any later version. |
| 13 |
|
| 14 |
This library is distributed in the hope that it will be useful, |
| 15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
Lesser General Public License for more details. |
| 18 |
|
| 19 |
You should have received a copy of the GNU Lesser General Public |
| 20 |
License along with this library; if not, write to the Free |
| 21 |
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 |
Boston, MA 02110 USA. |
| 23 |
*/ |
| 24 |
|
| 25 |
#import "PBXCommon.h" |
| 26 |
#import "PBXFileSystemSynchronizedRootGroup.h" |
| 27 |
#import "PBXFileReference.h" |
| 28 |
#import "PBXBuildFile.h" |
| 29 |
#import "NSString+PBXAdditions.h" |
| 30 |
|
| 31 |
@implementation PBXFileSystemSynchronizedRootGroup |
| 32 |
|
| 33 |
- (NSMutableArray *) synchronizedChildren |
| 34 |
{ |
| 35 |
NSFileManager *fm = [NSFileManager defaultManager]; |
| 36 |
NSDirectoryEnumerator *den = [fm enumeratorAtPath: _path]; |
| 37 |
NSMutableArray *result = [NSMutableArray array]; |
| 38 |
NSString *filePath = nil; |
| 39 |
NSMutableArray *fp = [NSMutableArray array]; |
| 40 |
|
| 41 |
while ((filePath = [den nextObject]) != nil) |
| 42 |
{ |
| 43 |
BOOL isDir = NO; |
| 44 |
NSString *fullPath = [_path stringByAppendingPathComponent: filePath]; |
| 45 |
|
| 46 |
if ([fm fileExistsAtPath: fullPath isDirectory: &isDir] && isDir == NO) |
| 47 |
{ |
| 48 |
PBXBuildFile *buildFile = [[PBXBuildFile alloc] init]; |
| 49 |
PBXFileReference *fileRef = nil; |
| 50 |
NSString *fpc = [filePath firstPathComponent]; |
| 51 |
NSString *path = filePath; |
| 52 |
|
| 53 |
AUTORELEASE(buildFile); |
| 54 |
|
| 55 |
if ([[fpc pathExtension] isEqualToString: @"xcassets"]) |
| 56 |
{ |
| 57 |
path = fpc; |
| 58 |
} |
| 59 |
|
| 60 |
if ([fp containsObject: path] == NO) |
| 61 |
{ |
| 62 |
fileRef = [[PBXFileReference alloc] initWithPath: path]; |
| 63 |
|
| 64 |
// NSLog(@"fileRef = %@", fileRef); |
| 65 |
AUTORELEASE(fileRef); |
| 66 |
[buildFile setFileRef: fileRef]; |
| 67 |
[result addObject: buildFile]; |
| 68 |
[fp addObject: path]; |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
// NSLog(@"result = %@", result); |
| 74 |
|
| 75 |
return result; |
| 76 |
} |
| 77 |
|
| 78 |
- (void) setPath: (NSString *)path |
| 79 |
{ |
| 80 |
[super setPath: path]; |
| 81 |
[self setChildren: [self synchronizedChildren]]; |
| 82 |
} |
| 83 |
|
| 84 |
@end |