浏览代码

UI: Add function to find default video save path

On windows this will return the documents\video directory, but on
linux/mac it'll just return $HOME for the time being because I don't
know if there really are any other appropriate adequate paths to use.
Perhaps someone else can be willing to fill this in if they wish.
jp9000 11 年之前
父节点
当前提交
765ac2a76b
共有 4 个文件被更改,包括 24 次插入0 次删除
  1. 4 0
      obs/platform-osx.mm
  2. 14 0
      obs/platform-windows.cpp
  3. 5 0
      obs/platform-x11.cpp
  4. 1 0
      obs/platform.hpp

+ 4 - 0
obs/platform-osx.mm

@@ -77,3 +77,7 @@ bool InitApplicationBundle()
 #endif
 }
 
+string GetDefaultVideoSavePath()
+{
+	return string(getenv("HOME"));
+}

+ 14 - 0
obs/platform-windows.cpp

@@ -23,6 +23,8 @@ using namespace std;
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
+#include <shellapi.h>
+#include <shlobj.h>
 
 static inline bool check_path(const char* data, const char *path,
 		string &output)
@@ -67,3 +69,15 @@ bool InitApplicationBundle()
 {
 	return true;
 }
+
+string GetDefaultVideoSavePath()
+{
+	wchar_t path_utf16[MAX_PATH];
+	char    path_utf8[MAX_PATH];
+
+	SHGetFolderPathW(NULL, CSIDL_MYVIDEO, NULL, SHGFP_TYPE_CURRENT,
+			path_utf16);
+
+	os_wcs_to_utf8(path_utf16, MAX_PATH, path_utf8);
+	return string(path_utf8);
+}

+ 5 - 0
obs/platform-x11.cpp

@@ -101,3 +101,8 @@ bool InitApplicationBundle()
 {
 	return true;
 }
+
+string GetDefaultVideoSavePath()
+{
+	return string(getenv("HOME"));
+}

+ 1 - 0
obs/platform.hpp

@@ -39,3 +39,4 @@ void GetMonitors(std::vector<MonitorInfo> &monitors);
 /* Updates the working directory for OSX application bundles */
 bool InitApplicationBundle();
 
+std::string GetDefaultVideoSavePath();