From 9cfd2325db6efecd2bf0d3f9fb05bf2f301c1e85 Mon Sep 17 00:00:00 2001 From: Alessandro Volz Date: Thu, 29 Mar 2018 12:03:07 +0200 Subject: [PATCH] when burning Weasis customization files, merge directories --- Horos/Sources/BurnerWindowController.m | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Horos/Sources/BurnerWindowController.m b/Horos/Sources/BurnerWindowController.m index 8a9368deae..ebfb3c3fa2 100644 --- a/Horos/Sources/BurnerWindowController.m +++ b/Horos/Sources/BurnerWindowController.m @@ -1052,9 +1052,21 @@ - (void) prepareCDContent: (NSMutableArray*) dbObjects :(NSMutableArray*) origin [[NSFileManager defaultManager] copyItemAtPath:[weasisPath stringByAppendingPathComponent:subpath] toPath:[burnFolder stringByAppendingPathComponent:subpath] error:NULL]; NSString *burnWeasisPath = [burnFolder stringByAppendingPathComponent:@"weasis"]; - for (NSString *weasisPath in [Horos WeasisCustomizationPaths]) - for (NSString* subpath in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:weasisPath error:NULL]) - [[NSFileManager defaultManager] copyItemAtPath:[weasisPath stringByAppendingPathComponent:subpath] toPath:[burnWeasisPath stringByAppendingPathComponent:subpath] error:NULL]; + NSArray *skips = @[ @".DS_Store" ]; + for (NSString *weasisPath in [[Horos WeasisCustomizationPaths] reverseObjectEnumerator]) { // reversed to mimic the WebPortal priorities + NSDirectoryEnumerator *de = [[NSFileManager defaultManager] enumeratorAtPath:weasisPath]; + for (NSString *subpath in de) + if (![skips containsObject:subpath.lastPathComponent]) { + NSString *source = [weasisPath stringByAppendingPathComponent:subpath], *dest = [burnWeasisPath stringByAppendingPathComponent:subpath];; + if ([de.fileAttributes[NSFileType] isEqual:NSFileTypeDirectory]) { + [[NSFileManager defaultManager] createDirectoryAtPath:dest withIntermediateDirectories:YES attributes:nil error:NULL]; + } else { + if ([[NSFileManager defaultManager] fileExistsAtPath:dest]) + [[NSFileManager defaultManager] removeItemAtPath:dest error:NULL]; + [[NSFileManager defaultManager] copyItemAtPath:[weasisPath stringByAppendingPathComponent:subpath] toPath:dest error:NULL]; + } + } + } // Change Label in Autorun.inf NSStringEncoding encoding;