Changeset 1314

Show
Ignore:
Timestamp:
08/21/2010 08:43:14 PM (18 months ago)
Author:
gbooker
Message:

In the always copy case, check to see if files are actually different before determining that the copy should take place. Reduces copy when there's no need.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/CommonMediaPlayer/Classes/CMPPlayerManager.h

    r1259 r1314  
    7272} 
    7373 
     74static inline BOOL needCopyWithAlways(NSString *frameworkPath, NSString *myFrameworkPath) 
     75{ 
     76        NSFileManager *fm = [NSFileManager defaultManager]; 
     77        BOOL isDir = NO; 
     78        FrameworkLoadPrint(@"Checking if dir exists"); 
     79        if(![fm fileExistsAtPath:frameworkPath isDirectory:&isDir] || !isDir) 
     80                return YES; 
     81         
     82        NSBundle *bundle = [NSBundle bundleWithPath:frameworkPath]; 
     83        NSString *execPath = [bundle executablePath]; 
     84        NSBundle *myBundle = [NSBundle bundleWithPath:myFrameworkPath]; 
     85        NSString *myExecPath = [myBundle executablePath]; 
     86        if(![fm contentsEqualAtPath:execPath andPath:myExecPath]) 
     87                return YES; 
     88        return NO; 
     89} 
     90 
    7491static BOOL createDirectoryTree(NSFileManager *fm, NSString *directory) 
    7592{ 
     
    169186        NSString *frameworkPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Frameworks/CommonMediaPlayer.framework"]; 
    170187        FrameworkLoadPrint(@"Path is at %@", frameworkPath); 
     188        NSString *frameworkInFrap = [frapPath stringByAppendingPathComponent:@"Contents/Frameworks/CommonMediaPlayer.framework"]; 
    171189#ifdef FrameworkAlwaysCopy 
    172         BOOL neededCopy = YES; 
     190        BOOL neededCopy = needCopyWithAlways(frameworkPath, frameworkInFrap); 
    173191#else 
    174192        BOOL neededCopy = needCopy(frameworkPath); 
     
    178196        { 
    179197                NSFileManager *fm = [NSFileManager defaultManager]; 
    180                 NSString *frameworkInFrap = [frapPath stringByAppendingPathComponent:@"Contents/Frameworks/CommonMediaPlayer.framework"]; 
    181198                FrameworkLoadPrint(@"Going to copy %@", frameworkInFrap); 
    182199                BOOL success = [fm removeFileAtPath:frameworkPath handler:nil];