]> granicus.if.org Git - handbrake/commitdiff
ports: add functions for looking up user config directory
authorjstebbins <jstebbins.hb@gmail.com>
Sun, 19 Apr 2015 14:38:38 +0000 (14:38 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Sun, 19 Apr 2015 14:38:38 +0000 (14:38 +0000)
These will be used by the CLI for loading custom user presets.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7105 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/configure.ac
libhb/module.defs
libhb/module.rules
libhb/platform/macosx/config.m [new file with mode: 0644]
libhb/ports.c
libhb/ports.h
macosx/HandBrake.xcodeproj/project.pbxproj
macosx/HandBrake.xcodeproj/xcshareddata/xcschemes/HandBrake [DEBUG].xcscheme
test/module.defs

index 21a0cac0719f179ab3822ed2f66fa6799eabe840..94e740dadcef904a93d16b739695ab7a925d68ee 100644 (file)
@@ -173,7 +173,7 @@ case $host in
     else
         HB_LIBS+=" -lpthreadGC2"
        fi
-    HB_LIBS+=" -lregex"
+    HB_LIBS+=" -lregex -luuid"
     ;;
   *)
     HB_LIBS+=" -ldl -lpthread"
index 79222a2fa9a21907f57e64a665c518bf5415d98c..445d66433234eaabc33409973583ab1635043203 100644 (file)
@@ -15,6 +15,7 @@ LIBHB.m4.out = $(patsubst $(LIBHB.src/)%.m4,$(LIBHB.build/)%,$(LIBHB.m4.in))
 
 LIBHB.c   = $(wildcard $(LIBHB.src/)*.c)
 LIBHB.c.o = $(patsubst $(SRC/)%.c,$(BUILD/)%.o,$(LIBHB.c))
+LIBHB.m.o = $(patsubst $(SRC/)%.m,$(BUILD/)%.o,$(LIBHB.m))
 LIBHB.d   = $(LIBHB.m4.out) $(LIBHB.h.out) \
     $(foreach n,$(LIBHB.prerequisites),$($n.INSTALL.target) )
 
@@ -30,6 +31,7 @@ LIBHB.a = $(LIBHB.build/)$(call TARGET.archive,handbrake)
 
 LIBHB.out += $(LIBHB.m4.out)
 LIBHB.out += $(LIBHB.c.o)
+LIBHB.out += $(LIBHB.m.o)
 LIBHB.out += $(LIBHB.h.out)
 LIBHB.out += $(LIBHB.a)
 
@@ -50,6 +52,7 @@ ifeq ($(BUILD.system),cygwin)
 else ifeq ($(BUILD.system),darwin)
     LIBHB.GCC.D += SYS_DARWIN
     LIBHB.c += $(wildcard $(LIBHB.src/)platform/macosx/*.c)
+    LIBHB.m += $(wildcard $(LIBHB.src/)platform/macosx/*.m)
 else ifeq ($(BUILD.system),linux)
     LIBHB.GCC.D += SYS_LINUX _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64
 else ifeq ($(BUILD.system),mingw)
@@ -168,7 +171,7 @@ else
 endif
 
 LIBHB.GCC.args.extra.dylib++ += -Wl,--out-implib,$(LIBHB.lib)
-LIBHB.GCC.l += ws2_32
+LIBHB.GCC.l += ws2_32 uuid
 ifeq ($(HAS.dlfcn),1)
     LIBHB.GCC.l += dl
 endif
index c92ababa2e0d6f189aa05c2c19236f4f0d7a7f35..65525cd07aaffb57e0f244014b3ab1bb5bc86714 100644 (file)
@@ -3,13 +3,16 @@ $(eval $(call import.MODULE.rules,LIBHB))
 libhb.build: $(LIBHB.a)
 
 $(LIBHB.a): | $(dir $(LIBHB.a))
-$(LIBHB.a): $(LIBHB.c.o) $(LIBHB.yasm.o)
+$(LIBHB.a): $(LIBHB.c.o) $(LIBHB.m.o) $(LIBHB.yasm.o)
        $(AR.exe) rsu $@ $^
 
 $(LIBHB.c.o): $(LIBHB.d)
 $(LIBHB.c.o): | $(dir $(LIBHB.c.o))
 $(LIBHB.c.o): $(BUILD/)%.o: $(SRC/)%.c
        $(call LIBHB.GCC.C_O,$@,$<)
+$(LIBHB.m.o): | $(dir $(LIBHB.m.o))
+$(LIBHB.m.o): $(BUILD/)%.o: $(SRC/)%.m
+       $(call LIBHB.GCC.C_O,$@,$<)
 
 $(LIBHB.m4.out): $(BUILD/)project/handbrake.m4
 $(LIBHB.m4.out): | $(dir $(LIBHB.m4.out))
diff --git a/libhb/platform/macosx/config.m b/libhb/platform/macosx/config.m
new file mode 100644 (file)
index 0000000..9fa86aa
--- /dev/null
@@ -0,0 +1,14 @@
+#import <Foundation/Foundation.h>
+/* #import <Cocoa/Cocoa.h> */
+
+void osx_get_user_config_directory(char path[512])
+{
+    @autoreleasepool {
+        NSArray *paths = NSSearchPathForDirectoriesInDomains(
+                        NSApplicationSupportDirectory, NSUserDomainMask, YES);
+        NSString *dir = paths[0];
+        strncpy(path, dir.UTF8String, 512);
+        path[511] = 0;
+    }
+}
+
index 048f478cfdd08a220295067fc58a4bbb9a6c9234..c75a7c943f1a68d63380d5aee72eaaaa18c6e461 100644 (file)
@@ -7,6 +7,10 @@
    For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
  */
 
+#ifdef SYS_MINGW
+#define _WIN32_WINNT 0x600
+#endif
+
 #ifdef USE_PTHREAD
 #ifdef SYS_LINUX
 #define _GNU_SOURCE
@@ -50,6 +54,7 @@
 #include <wchar.h>
 #include <mbctype.h>
 #include <locale.h>
+#include <shlobj.h>
 #endif
 
 #ifdef SYS_SunOS
@@ -492,6 +497,62 @@ int hb_platform_init()
     return result;
 }
 
+/************************************************************************
+ * Get app data config directory
+ ***********************************************************************/
+void hb_get_user_config_directory( char path[512] )
+{
+    /* Create the base */
+#if defined( SYS_CYGWIN ) || defined( SYS_MINGW )
+    WCHAR *wide_path;
+    SHGetKnownFolderPath(&FOLDERID_RoamingAppData, 0, NULL, &wide_path);
+    WideCharToMultiByte(CP_UTF8, 0, wide_path, -1, path, 512, NULL, NULL );
+    path[511] = 0;
+#elif defined( SYS_LINUX )
+    char *p;
+
+    if ((p = getenv("XDG_CONFIG_HOME")) != NULL)
+    {
+        strncpy(path, p, 511);
+        path[511] = 0;
+    }
+    else if ((p = getenv("HOME")) != NULL)
+    {
+        strncpy(path, p, 511);
+        path[511] = 0;
+        int len = strlen(path);
+        strncpy(path + len, "/.config", 511 - len - 1);
+        path[511] = 0;
+    }
+    else
+    {
+        hb_error("Failed to lookup user config directory!");
+        path[0] = 0;
+    }
+#elif defined( __APPLE__ )
+    osx_get_user_config_directory(path);
+#endif
+}
+
+/************************************************************************
+ * Get a user config filename for HB
+ ***********************************************************************/
+void hb_get_user_config_filename( char name[1024], char *fmt, ... )
+{
+    va_list args;
+
+    hb_get_user_config_directory( name );
+#if defined( SYS_CYGWIN ) || defined( SYS_MINGW )
+    strcat( name, "\\" );
+#else
+    strcat( name, "/" );
+#endif
+
+    va_start( args, fmt );
+    vsnprintf( &name[strlen(name)], 1024 - strlen(name), fmt, args );
+    va_end( args );
+}
+
 /************************************************************************
  * Get a temporary directory for HB
  ***********************************************************************/
index 649d3995f6f41bf221993688b2b8dfe8f95f4573..42cdede6a5a413a378f71dfa6d34996727964e98 100644 (file)
@@ -100,6 +100,11 @@ void hb_get_temporary_directory( char path[512] );
 void hb_get_tempory_filename( hb_handle_t *, char name[1024],
                               char * fmt, ... );
 
+#if defined( SYS_DARWIN )
+void osx_get_user_config_directory( char path[512] );
+#endif
+void hb_get_user_config_directory( char path[512] );
+void hb_get_user_config_filename( char name[1024], char *fmt, ... );
 /************************************************************************
  * Threads
  ***********************************************************************/
index a9a07e89a53d6f9cf301c3032f5fc07f14977c91..f5e289e2f102f95fd58879c645772f07cc200496 100644 (file)
                27D6C77314B102DA00B785E4 /* libxml2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 27D6C74014B102DA00B785E4 /* libxml2.a */; };
                3490BCB41614CF8D002A5AD7 /* HandBrake.icns in Resources */ = {isa = PBXBuildFile; fileRef = 3490BCB31614CF8D002A5AD7 /* HandBrake.icns */; };
                46AB433515F98A2B009C0961 /* DockTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 46AB433415F98A2B009C0961 /* DockTextField.m */; };
+               6F0D69A91AD0683100A39DCA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 273F204014ADBC210021BE6D /* Foundation.framework */; };
                A90A0CAF1988D57200DA65CE /* HBAudioTrackPreset.m in Sources */ = {isa = PBXBuildFile; fileRef = A90A0CAE1988D57200DA65CE /* HBAudioTrackPreset.m */; };
                A91017B41A64440A00039BFB /* HBSubtitles.m in Sources */ = {isa = PBXBuildFile; fileRef = A91017B31A64440A00039BFB /* HBSubtitles.m */; };
                A91726E7197291BC00D1AFEF /* HBChapterTitlesController.m in Sources */ = {isa = PBXBuildFile; fileRef = A91726E6197291BC00D1AFEF /* HBChapterTitlesController.m */; };
                                27D6C76B14B102DA00B785E4 /* libtheora.a in Frameworks */,
                                27D6C76D14B102DA00B785E4 /* libvorbis.a in Frameworks */,
                                27D6C76F14B102DA00B785E4 /* libvorbisenc.a in Frameworks */,
+                               6F0D69A91AD0683100A39DCA /* Foundation.framework in Frameworks */,
                                22DD2C4B177B95DA00EF50D3 /* libvpx.a in Frameworks */,
                                27D6C77114B102DA00B785E4 /* libx264.a in Frameworks */,
                                27D6C77314B102DA00B785E4 /* libxml2.a in Frameworks */,
index 689602912f4a8466ba5213a1929a86f3bb310135..04c6afb70ca1b8166a45dd8e9bb518be12453c2a 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <Scheme
    LastUpgradeVersion = "0630"
-   version = "1.3">
+   version = "1.8">
    <BuildAction
       parallelizeBuildables = "YES"
       buildImplicitDependencies = "YES">
@@ -38,7 +38,7 @@
    </BuildAction>
    <TestAction
       selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
-      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
       shouldUseLaunchSchemeArgsEnv = "YES"
       buildConfiguration = "debug">
       <Testables>
       ignoresPersistentStateOnLaunch = "NO"
       debugDocumentVersioning = "YES"
       allowLocationSimulation = "YES">
-      <BuildableProductRunnable
-         runnableDebuggingMode = "0">
+      <BuildableProductRunnable>
          <BuildableReference
             BuildableIdentifier = "primary"
-            BlueprintIdentifier = "273F203814ADBC200021BE6D"
-            BuildableName = "HandBrake.app"
-            BlueprintName = "HandBrake"
+            BlueprintIdentifier = "273F1FFE14ADAE950021BE6D"
+            BuildableName = "HandBrakeCLI"
+            BlueprintName = "HandBrakeCLI"
             ReferencedContainer = "container:HandBrake.xcodeproj">
          </BuildableReference>
       </BuildableProductRunnable>
index 1f794e93abe0824c66690bb21cf5c11f419f2bce..5bc8f1ffddccd0b58ab8308e8f22930241b141d5 100644 (file)
@@ -44,7 +44,7 @@ BUILD.out += $(TEST.install.exe)
 TEST.GCC.I += $(LIBHB.GCC.I)
 
 ifeq ($(BUILD.system),darwin)
-    TEST.GCC.f += IOKit CoreServices AudioToolbox
+    TEST.GCC.f += IOKit CoreServices AudioToolbox Foundation
     TEST.GCC.l += iconv
 else ifeq ($(BUILD.system),linux)
     TEST.GCC.l += pthread dl m
@@ -65,7 +65,7 @@ ifeq (1,$(HAS.pthread))
 else
     TEST.GCC.l += pthreadGC2
 endif
-    TEST.GCC.l += iconv ws2_32 regex
+    TEST.GCC.l += iconv ws2_32 regex uuid
     TEST.GCC.D += PTW32_STATIC_LIB
     TEST.GCC.args.extra.exe++ += -static
 endif #   (1-mingw,$(BUILD.cross)-$(BUILD.system))