]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxStandardPaths::GetDocumentsDir() (patch 1214360)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 17 Apr 2006 01:12:04 +0000 (01:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 17 Apr 2006 01:12:04 +0000 (01:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38777 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

13 files changed:
docs/changes.txt
docs/latex/wx/stdpaths.tex
include/wx/mac/carbon/private.h
include/wx/mac/classic/private.h
include/wx/mac/corefoundation/stdpaths.h
include/wx/msw/stdpaths.h
include/wx/stdpaths.h
samples/console/console.cpp
src/common/stdpbase.cpp
src/mac/carbon/utils.cpp
src/mac/classic/utils.cpp
src/mac/corefoundation/stdpaths_cf.cpp
src/msw/stdpaths.cpp

index 01d4dbd98215375bcb1c96ca6260e53ffce1d5b2..b180989118a6c3aecc54b30ec003b8970236a939 100644 (file)
@@ -40,6 +40,7 @@ All:
 - Many fixes for UTF-16/32 handling in Unicode builds
 - wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag.
 - Added wxStandardPaths::GetResourcesDir() and GetLocalizedResourcesDir()
+- Added wxStandardPaths::GetDocumentsDir() (Ken Thomases)
 - Added wxStringTokenizer::GetLastDelimiter(); improved documentation.
 - Fixed wxTextFile in Unicode build
 - Speed improvements to wxRegEx when matching is done in a loop such as
index 172c14cdc9a30626249a9b2b059ccdec32752a13..c765bca647ef559ccd3a28ffdb5065e7da9108fd 100644 (file)
@@ -95,6 +95,20 @@ Example return values:
 \helpref{GetLocalDataDir}{wxstandardpathsgetlocaldatadir}
 
 
+\membersection{wxStandardPaths::GetDocumentsDir}\label{wxstandardpathsgetdocumentsdir}
+
+\func{wxString}{GetDocumentsDir}{\void}
+
+Return the directory containing the current user's documents.
+
+Example return values:
+\begin{itemize}
+    \item Unix: \tt{~} (the home directory)
+    \item Windows: \texttt{C:$\backslash$Documents and Settings$\backslash$\textit{username}$\backslash$Documents}
+    \item Mac: \texttt{~/Documents}
+\end{itemize}
+
+
 \membersection{wxStandardPaths::GetInstallPrefix}\label{wxstandardpathsgetinstallprefix}
 
 \func{wxString}{GetInstallPrefix}{\void}
index 703ad07254d7309cd132aa9a0606b79be8b1ff4a..c8a9c67893eb251e6b83e88f66990b9d3c9e53d7 100644 (file)
@@ -196,6 +196,9 @@ WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
 WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ;
 
 // utils.h
+WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum,
+                                                OSType folderType,
+                                                Boolean createFolder);
 WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
                                      OSType folderType,
                                      Boolean createFolder);
index f16a72067ee915a72eb7fa55be3262f06eb1221e..d2c1c6986d834522e2d2a082465b4ee22c83fd1b 100644 (file)
@@ -124,6 +124,9 @@ WXDLLEXPORT wxString wxUnix2MacFilename( const wxChar *s);
 #  endif
 
 // utils.h
+WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum,
+                                                OSType folderType,
+                                                Boolean createFolder);
 WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
                                      OSType folderType,
                                      Boolean createFolder);
index 00b1ffbdf714f3da4162ec5c8c6f3912d578ee0b..a73ca4b5149b6ad7d28b8bfd48ae8505f15e8aae 100644 (file)
@@ -42,6 +42,7 @@ public:
     virtual wxString GetResourcesDir() const;
     virtual wxString GetLocalizedResourcesDir(const wxChar *lang,
                                               ResourceCat category) const;
+    virtual wxString GetDocumentsDir() const;
 
 protected:
     // this function can be called with any of CFBundleCopyXXXURL function
index 5273872dcedb40b643646e1754c76ad76fbab773..56bae840f50963784e43278862c97555e310a529 100644 (file)
@@ -26,6 +26,7 @@ public:
     virtual wxString GetUserDataDir() const;
     virtual wxString GetUserLocalDataDir() const;
     virtual wxString GetPluginsDir() const;
+    virtual wxString GetDocumentsDir() const;
 
 protected:
     // get the path corresponding to the given standard CSIDL_XXX constant
index b3b54d41061b1d42b0547ed9ce6ad0b2e3574fca..1be4077d6596bf96a4ae66429b6439f84e608178 100644 (file)
@@ -111,6 +111,12 @@ public:
         return GetResourcesDir() + wxFILE_SEP_PATH + lang;
     }
 
+    // return the "Documents" directory for the current user
+    //
+    // C:\Documents and Settings\username\Documents under Windows,
+    // $HOME under Unix and ~/Documents under Mac
+    virtual wxString GetDocumentsDir() const;
+
 
     // virtual dtor for the base class
     virtual ~wxStandardPathsBase();
@@ -149,6 +155,7 @@ public:
     virtual wxString GetLocalDataDir() const { return m_prefix; }
     virtual wxString GetUserDataDir() const { return m_prefix; }
     virtual wxString GetPluginsDir() const { return m_prefix; }
+    virtual wxString GetDocumentsDir() const { return m_prefix; }
 
 private:
     wxString m_prefix;
index 06662dde589dd8529a4f52c7b1008af934ca7922..14e781d047f1d1846b1faf73f2658978a4baa5f3 100644 (file)
@@ -2684,6 +2684,7 @@ static void TestStandardPaths()
     wxPrintf(_T("Data dir (sys local):\t%s\n"), stdp.GetLocalDataDir().c_str());
     wxPrintf(_T("Data dir (user):\t%s\n"), stdp.GetUserDataDir().c_str());
     wxPrintf(_T("Data dir (user local):\t%s\n"), stdp.GetUserLocalDataDir().c_str());
+    wxPrintf(_T("Documents dir:\t\t%s\n"), stdp.GetDocumentsDir().c_str());
     wxPrintf(_T("Plugins dir:\t\t%s\n"), stdp.GetPluginsDir().c_str());
     wxPrintf(_T("Resources dir:\t\t%s\n"), stdp.GetResourcesDir().c_str());
     wxPrintf(_T("Localized res. dir:\t%s\n"),
index 6f9bba7c978ced79ea4c8fcc073a77c3534bbe58..18ad257b928229bf56eb1e518faf05110edbaed4 100644 (file)
@@ -73,6 +73,11 @@ wxString wxStandardPathsBase::GetUserLocalDataDir() const
     return GetUserDataDir();
 }
 
+wxString wxStandardPathsBase::GetDocumentsDir() const
+{
+    return wxFileName::GetHomeDir();
+}
+
 /* static */
 wxString wxStandardPathsBase::AppendAppName(const wxString& dir)
 {
index 5cb7a352f9001119ab11a878fc402b3f75fc80cc..9c22b9581861932804010d24b3b3496678eaec5c 100644 (file)
@@ -521,7 +521,7 @@ bool wxIsBusy()
 
 #if wxUSE_BASE
 
-wxString wxMacFindFolder( short        vol,
+wxString wxMacFindFolderNoSeparator( short        vol,
               OSType       folderType,
               Boolean      createFolder)
 {
@@ -529,11 +529,20 @@ wxString wxMacFindFolder( short        vol,
     wxString strDir ;
 
     if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr)
-        strDir = wxMacFSRefToPath( &fsRef ) + wxFILE_SEP_PATH ;
+    {
+        strDir = wxMacFSRefToPath( &fsRef );
+    }
 
     return strDir ;
 }
 
+wxString wxMacFindFolder( short        vol,
+              OSType       folderType,
+              Boolean      createFolder)
+{
+    return wxMacFindFolderNoSeparator(vol, folderType, createFolder) + wxFILE_SEP_PATH;
+}
+
 #endif // wxUSE_BASE
 
 #if wxUSE_GUI
index 78cbfd0da7e816a3dadb1e97eda4c86fe7e45680..f5a8ff1bd5738a80979e3b71525fb0a368e369d3 100644 (file)
@@ -372,7 +372,7 @@ bool wxIsBusy()
 
 #if wxUSE_BASE
 
-wxString wxMacFindFolder( short        vol,
+wxString wxMacFindFolderNoSeparator( short        vol,
               OSType       folderType,
               Boolean      createFolder)
 {
@@ -385,12 +385,19 @@ wxString wxMacFindFolder( short        vol,
         FSSpec file ;
         if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
         {
-            strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ;
+            strDir = wxMacFSSpec2MacFilename( &file );
         }
     }
     return strDir ;
 }
 
+wxString wxMacFindFolder( short        vol,
+              OSType       folderType,
+              Boolean      createFolder)
+{
+    return wxMacFindFolderNoSeparator(vol, folderType, createFolder) + wxFILE_SEP_PATH;
+}
+
 #endif // wxUSE_BASE
 
 #if wxUSE_GUI
index eb6e0367bf9ed7446a13d9bd464d6a94a8a3beb9..2b2cf9cba0061427f41435224d0a63663e71d045 100644 (file)
@@ -31,6 +31,7 @@
 #include "wx/mac/private.h"
 #endif
 #include "wx/mac/corefoundation/cfstring.h"
+#include "wx/mac/private.h"
 
 #if defined(__DARWIN__)
 #include <CoreFoundation/CFBundle.h>
@@ -106,6 +107,20 @@ wxString wxStandardPathsCF::GetFromFunc(wxCFURLRef (*func)(wxCFBundleRef)) const
     return ret;
 }
 
+wxString wxStandardPathsCF::GetDocumentsDir() const
+{
+    return wxMacFindFolderNoSeparator
+        (
+#if TARGET_API_MAC_OSX
+        kUserDomain,
+#else
+        kOnSystemDisk,
+#endif
+        kDocumentsFolderType,
+        kCreateFolder
+        );
+}
+
 // ----------------------------------------------------------------------------
 // wxStandardPathsCF public API
 // ----------------------------------------------------------------------------
index 5e9de59ee3b2ca0bb81cb22044589ca958e6e875..7eef3af3a0c8dbca0ef6dfa162a57c77b3a709af 100644 (file)
@@ -68,6 +68,10 @@ static const wxChar *TRACE_MASK = _T("stdpaths");
     #define CSIDL_PROGRAM_FILES   0x0026
 #endif
 
+#ifndef CSIDL_PERSONAL
+    #define CSIDL_PERSONAL        0x0005
+#endif
+
 #ifndef SHGFP_TYPE_CURRENT
     #define SHGFP_TYPE_CURRENT 0
 #endif
@@ -75,7 +79,6 @@ static const wxChar *TRACE_MASK = _T("stdpaths");
 #ifndef SHGFP_TYPE_DEFAULT
     #define SHGFP_TYPE_DEFAULT 1
 #endif
-
 // ----------------------------------------------------------------------------
 // module globals
 // ----------------------------------------------------------------------------
@@ -262,6 +265,11 @@ wxString wxStandardPaths::GetAppDir()
     return fn.GetPath();
 }
 
+wxString wxStandardPaths::GetDocumentsDir() const
+{
+    return DoGetDirectory(CSIDL_PERSONAL);
+}
+
 // ----------------------------------------------------------------------------
 // public functions
 // ----------------------------------------------------------------------------