summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2021-01-05 18:32:48 +0100
committerDamiano Galassi <[email protected]>2021-01-05 18:32:48 +0100
commitd9cc5955d7137711c24d46ab05abdfc138a022fb (patch)
treed223e76267c2b90b95236d5e2f3372a708433beb /macosx
parent5a625a6762b6378c2bab15d4634bab8f2e503ab5 (diff)
MacGUI: use NSFileManager to get the Movies directory URL.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/HBController.m4
-rw-r--r--macosx/HBPreferencesController.m5
-rw-r--r--macosx/HBUtilities.h6
-rw-r--r--macosx/HBUtilities.m5
4 files changed, 15 insertions, 5 deletions
diff --git a/macosx/HBController.m b/macosx/HBController.m
index 021242193..2fdc6eb8f 100644
--- a/macosx/HBController.m
+++ b/macosx/HBController.m
@@ -188,11 +188,9 @@ static void *HBControllerLogLevelContext = &HBControllerLogLevelContext;
#else
_destinationURL = [NSUserDefaults.standardUserDefaults URLForKey:HBLastDestinationDirectoryURL];
#endif
-
if (!_destinationURL || [NSFileManager.defaultManager fileExistsAtPath:_destinationURL.path isDirectory:nil] == NO)
{
- _destinationURL = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSMoviesDirectory, NSUserDomainMask, YES) firstObject]
- isDirectory:YES];
+ _destinationURL = HBUtilities.defaultDestinationURL;
}
#ifdef __SANDBOX_ENABLED__
diff --git a/macosx/HBPreferencesController.m b/macosx/HBPreferencesController.m
index 208121635..6da6a49fe 100644
--- a/macosx/HBPreferencesController.m
+++ b/macosx/HBPreferencesController.m
@@ -5,6 +5,8 @@
#import "HBPreferencesController.h"
+@import HandBrakeKit.HBUtilities;
+
NSString * const HBShowOpenPanelAtLaunch = @"HBShowOpenPanelAtLaunch";
NSString * const HBShowSummaryPreview = @"HBShowSummaryPreview";
@@ -77,8 +79,7 @@ NSString * const HBQueueWorkerCounts = @"HBQueueWorkerCounts";
*/
+ (void)registerUserDefaults
{
- NSString *moviesDirectory = [NSSearchPathForDirectoriesInDomains(NSMoviesDirectory, NSUserDomainMask, YES) firstObject];
- NSURL *moviesURL = [NSURL fileURLWithPath:moviesDirectory isDirectory:YES];
+ NSURL *moviesURL = HBUtilities.defaultDestinationURL;
[[NSUserDefaults standardUserDefaults] registerDefaults:@{
HBShowOpenPanelAtLaunch: @YES,
diff --git a/macosx/HBUtilities.h b/macosx/HBUtilities.h
index fd4704624..285ee4c00 100644
--- a/macosx/HBUtilities.h
+++ b/macosx/HBUtilities.h
@@ -25,6 +25,12 @@ NS_ASSUME_NONNULL_BEGIN
+ (nullable NSURL *)appSupportURL;
/**
+ * Returns the default destination URL
+ */
++ (nullable NSURL *)defaultDestinationURL;
+
+
+/**
* Returns the url of the current version documentation.
*/
@property (nonatomic, readonly, class) NSURL *documentationURL;
diff --git a/macosx/HBUtilities.m b/macosx/HBUtilities.m
index 218824162..5fabfe77c 100644
--- a/macosx/HBUtilities.m
+++ b/macosx/HBUtilities.m
@@ -35,6 +35,11 @@ static BOOL hb_resolveBookmarks = YES;
return appSupportURL;
}
++ (NSURL *)defaultDestinationURL
+{
+ return [[NSFileManager.defaultManager URLsForDirectory:NSMoviesDirectory inDomains:NSUserDomainMask] firstObject];
+}
+
+ (NSURL *)documentationURL
{
return [NSURL URLWithString:@"https://handbrake.fr/docs/en/1.3.0/"];