Skip to content

Commit

Permalink
Merge pull request #304 from volz-io/aglv
Browse files Browse the repository at this point in the history
#299 again
  • Loading branch information
fvpolpeta authored Mar 29, 2018
2 parents 531e005 + 9cfd232 commit 682bc83
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
19 changes: 19 additions & 0 deletions Horos/Sources/BurnerWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ This file is part of the Horos Project (www.horosproject.org)
#import "DicomFileDCMTKCategory.h"
#import "DCMUIDs.h"
#import "DicomDatabase+DCMTK.h"
#import "Horos.h"

@implementation BurnerWindowController

Expand Down Expand Up @@ -1045,10 +1046,28 @@ - (void) prepareCDContent: (NSMutableArray*) dbObjects :(NSMutableArray*) origin
{
thread.name = NSLocalizedString( @"Burning...", nil);
thread.status = NSLocalizedString( @"Adding Weasis...", nil);

NSString* weasisPath = [[AppController sharedAppController] weasisBasePath];
for (NSString* subpath in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:weasisPath error:NULL])
[[NSFileManager defaultManager] copyItemAtPath:[weasisPath stringByAppendingPathComponent:subpath] toPath:[burnFolder stringByAppendingPathComponent:subpath] error:NULL];

NSString *burnWeasisPath = [burnFolder stringByAppendingPathComponent:@"weasis"];
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;
NSString *autorunInf = [NSString stringWithContentsOfFile: [burnFolder stringByAppendingPathComponent: @"Autorun.inf"] usedEncoding: &encoding error: nil];
Expand Down
2 changes: 2 additions & 0 deletions Horos/Sources/Horos.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSDateComponents *)components:(NSCalendarUnit)flags fromDate:(NSDate *)date;
+ (NSString *):(NSDate *)date descriptionWithCalendarFormat:(NSString *)format;

+ (NSArray<NSString *> *)WeasisCustomizationPaths;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions Horos/Sources/Horos.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,8 @@ + (NSDateComponents *)components:(NSCalendarUnit)flags fromDate:(NSDate *)date {
#pragma clang diagnostic pop
}

+ (NSArray<NSString *> *)WeasisCustomizationPaths {
return @[ [@"~/Library/Application Support/Horos/Weasis" stringByExpandingTildeInPath], @"/Library/Application Support/Horos/Weasis" ];
}

@end
5 changes: 3 additions & 2 deletions Horos/Sources/WebPortalConnection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ This file is part of the Horos Project (www.horosproject.org)
#import "N2Alignment.h"
#import "AppController.h"
#import "PluginManager.h"
#import "Horos.h"

#import "JSON.h"

Expand Down Expand Up @@ -495,8 +496,8 @@ - (void) alive:(id) sender
{
#ifndef OSIRIX_LIGHT
BOOL assigned = false;
for (NSString *dir in self.portal.dirsToScanForFiles) {
NSString *path = [dir stringByAppendingPathComponent:self.requestedPath];
for (NSString *dir in [Horos WeasisCustomizationPaths]) {
NSString *path = [dir stringByAppendingPathComponent:[self.requestedPath substringFromIndex:8]];
BOOL isDir;
if ([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir] && !isDir)
if ((response.data = [NSData dataWithContentsOfFile:path])) {
Expand Down

0 comments on commit 682bc83

Please sign in to comment.