summaryrefslogtreecommitdiffstats
path: root/macosx/Controller.m
diff options
context:
space:
mode:
authordynaflash <[email protected]>2010-08-06 04:28:33 +0000
committerdynaflash <[email protected]>2010-08-06 04:28:33 +0000
commitba8dab758b4d8edbe76332d3bc8b33424c86c4b0 (patch)
treea8a01cc0b4c4cc34c59338ff8919991ad72525e4 /macosx/Controller.m
parentcf982f896f80ed72e3c046dee0af49d1a1f4c9e6 (diff)
MacGui: Store live previews in a sub directory in "~/Library/Application Support/HandBrake/Previews" named by pidnum.
- Allows multi-instances to encode live previews without overwriting the live preview for any other instance (since previously we assumed single instance so there was just one live preview file for each container. - Clean up of the previews directory when a single instance is laucnhed to make sure we do not build up a pile of old previews. - Removed old code for live previews which handled the deprecated avi and ogm containers. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3472 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/Controller.m')
-rw-r--r--macosx/Controller.m38
1 files changed, 36 insertions, 2 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m
index 86674adea..672d44030 100644
--- a/macosx/Controller.m
+++ b/macosx/Controller.m
@@ -129,6 +129,34 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
* pid number for this instance in the case of multi-instance encoding. */
hbInstanceNum = [self hbInstances];
+ /* If we are a single instance it is safe to clean up the previews if there are any
+ * left over. This is a bit of a kludge but will prevent a build up of old instance
+ * live preview cruft. No danger of removing an active preview directory since they
+ * are created later in HBPreviewController if they don't exist at the moment a live
+ * preview encode is initiated. */
+ if (hbInstanceNum == 1)
+ {
+ NSString *PreviewDirectory = [NSString stringWithFormat:@"~/Library/Application Support/HandBrake/Previews"];
+ PreviewDirectory = [PreviewDirectory stringByExpandingTildeInPath];
+ NSError *error;
+ NSArray *files = [ [NSFileManager defaultManager] contentsOfDirectoryAtPath: PreviewDirectory error: &error ];
+ for( NSString *file in files )
+ {
+ if( file != @"." && file != @".." )
+ {
+ [ [NSFileManager defaultManager] removeItemAtPath: [ PreviewDirectory stringByAppendingPathComponent: file ] error: &error ];
+ if( error )
+ {
+ //an error occurred...
+ [self writeToActivityLog: "Could not remove existing preview at : %s",[file UTF8String] ];
+ }
+ }
+ }
+
+ }
+
+
+
/* Call UpdateUI every 1/2 sec */
[[NSRunLoop currentRunLoop] addTimer:[NSTimer
@@ -284,13 +312,19 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It
[self writeToActivityLog: "Pid for this instance:%d", pidNum];
/* Tell fQueueController what our pidNum is */
[fQueueController setPidNum:pidNum];
+
+ hbInstances++;
}
- hbInstances++;
}
- }
+ }
return hbInstances;
}
+- (int) getPidnum
+{
+ return pidNum;
+}
+
#pragma mark -
- (void) didDimissReloadQueue: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo