}
return buffer;
}
+
+/**
+ * @brief Get Windows directory.
+ * @return Windows directory.
+ */
+String env_GetWindowsDirectory()
+{
+ TCHAR buf[MAX_PATH] = {0};
+ GetWindowsDirectory(buf, MAX_PATH);
+ return buf;
+}
+
+/**
+ * @brief Return User's My Documents Folder.
+ * This function returns full path to User's My Documents -folder.
+ * @param [in] hWindow Parent window.
+ * @return Full path to My Documents -folder.
+ */
+String env_GetMyDocuments(HWND hWindow)
+{
+ LPITEMIDLIST pidl;
+ LPMALLOC pMalloc;
+ String path;
+
+ HRESULT rv = SHGetSpecialFolderLocation(hWindow, CSIDL_PERSONAL, &pidl);
+ if (rv == S_OK)
+ {
+ TCHAR szPath[MAX_PATH] = {0};
+ if (SHGetPathFromIDList(pidl, szPath))
+ {
+ path = szPath;
+ }
+
+ SHGetMalloc(&pMalloc);
+ pMalloc->Free(pidl);
+ pMalloc->Release();
+ }
+ return path;
+}
String env_GetTempFileName(LPCTSTR lpPathName, LPCTSTR lpPrefixString,
int * pnerr = NULL);
+String env_GetWindowsDirectory();
+String env_GetMyDocuments(HWND hWindow);
#endif // _ENVIRONMENT_H_
#include "stdafx.h"
#include <sys/stat.h>
#include "UnicodeString.h"
+#include "Environment.h"
#include "FileOrFolderSelect.h"
#include "coretools.h"
#include "paths.h"
bRetVal = GetSaveFileName((OPENFILENAME *)&ofn);
// common file dialog populated sSelectedFile variable's buffer
sSelectedFile.ReleaseBuffer();
- SetCurrentDirectory(paths_GetWindowsDirectory().c_str()); // Free handle held by GetOpenFileName
+ SetCurrentDirectory(env_GetWindowsDirectory().c_str()); // Free handle held by GetOpenFileName
if (bRetVal)
path = sSelectedFile;
BOOL bRetVal = GetOpenFileName((OPENFILENAME *)&ofn);
// common file dialog populated sSelectedFile variable's buffer
sSelectedFile.ReleaseBuffer();
- SetCurrentDirectory(paths_GetWindowsDirectory().c_str()); // Free handle held by GetOpenFileName
+ SetCurrentDirectory(env_GetWindowsDirectory().c_str()); // Free handle held by GetOpenFileName
if (bRetVal)
{
#include "stdafx.h"
#include "UnicodeString.h"
+#include "Environment.h"
#include "OptionsMgr.h"
#include "Merge.h"
#include "AboutDlg.h"
*/
CString CMergeApp::GetDefaultEditor()
{
- CString path = paths_GetWindowsDirectory().c_str();
+ CString path = env_GetWindowsDirectory().c_str();
path += _T("\\NOTEPAD.EXE");
return path;
}
*/
CString CMergeApp::GetDefaultFilterUserPath(BOOL bCreate /*=FALSE*/)
{
- CString pathMyFolders = paths_GetMyDocuments(NULL).c_str();
+ CString pathMyFolders = env_GetMyDocuments(NULL).c_str();
CString pathFilters(pathMyFolders);
if (pathFilters.Right(1) != _T("\\"))
pathFilters += _T("\\");
return _T("");
}
-/**
- * @brief Get Windows directory.
- * @return Windows directory.
- */
-String paths_GetWindowsDirectory()
-{
- TCHAR buf[MAX_PATH] = {0};
- GetWindowsDirectory(buf, MAX_PATH);
- return buf;
-}
-
-/**
- * @brief Return User's My Documents Folder.
- * This function returns full path to User's My Documents -folder.
- * @param [in] hWindow Parent window.
- * @return Full path to My Documents -folder.
- */
-String paths_GetMyDocuments(HWND hWindow)
-{
- LPITEMIDLIST pidl;
- LPMALLOC pMalloc;
- String path;
-
- HRESULT rv = SHGetSpecialFolderLocation(hWindow, CSIDL_PERSONAL, &pidl);
- if (rv == S_OK)
- {
- TCHAR szPath[MAX_PATH] = {0};
- if (SHGetPathFromIDList(pidl, szPath))
- {
- path = szPath;
- }
-
- SHGetMalloc(&pMalloc);
- pMalloc->Free(pidl);
- pMalloc->Release();
- }
- return path;
-}
String paths_GetLastSubdir(const String & path);
BOOL paths_IsPathAbsolute(const String & path);
String paths_EnsurePathExist(const String & sPath);
-String paths_GetWindowsDirectory();
-String paths_GetMyDocuments(HWND hWindow);
#endif // paths_h_included