added wxStandardPaths::GetDocumentsDir() (patch 1214360)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38777 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-04-17 01:12:04 +00:00
parent af6c0f1de7
commit 17af82fb4c
13 changed files with 80 additions and 5 deletions

View File

@@ -40,6 +40,7 @@ All:
- Many fixes for UTF-16/32 handling in Unicode builds - Many fixes for UTF-16/32 handling in Unicode builds
- wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag. - wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag.
- Added wxStandardPaths::GetResourcesDir() and GetLocalizedResourcesDir() - Added wxStandardPaths::GetResourcesDir() and GetLocalizedResourcesDir()
- Added wxStandardPaths::GetDocumentsDir() (Ken Thomases)
- Added wxStringTokenizer::GetLastDelimiter(); improved documentation. - Added wxStringTokenizer::GetLastDelimiter(); improved documentation.
- Fixed wxTextFile in Unicode build - Fixed wxTextFile in Unicode build
- Speed improvements to wxRegEx when matching is done in a loop such as - Speed improvements to wxRegEx when matching is done in a loop such as

View File

@@ -95,6 +95,20 @@ Example return values:
\helpref{GetLocalDataDir}{wxstandardpathsgetlocaldatadir} \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} \membersection{wxStandardPaths::GetInstallPrefix}\label{wxstandardpathsgetinstallprefix}
\func{wxString}{GetInstallPrefix}{\void} \func{wxString}{GetInstallPrefix}{\void}

View File

@@ -196,6 +196,9 @@ WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ; WXDLLEXPORT void wxMacFilename2FSSpec( const wxString &path , FSSpec *spec ) ;
// utils.h // utils.h
WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum,
OSType folderType,
Boolean createFolder);
WXDLLEXPORT wxString wxMacFindFolder(short vRefNum, WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
OSType folderType, OSType folderType,
Boolean createFolder); Boolean createFolder);

View File

@@ -124,6 +124,9 @@ WXDLLEXPORT wxString wxUnix2MacFilename( const wxChar *s);
# endif # endif
// utils.h // utils.h
WXDLLEXPORT wxString wxMacFindFolderNoSeparator(short vRefNum,
OSType folderType,
Boolean createFolder);
WXDLLEXPORT wxString wxMacFindFolder(short vRefNum, WXDLLEXPORT wxString wxMacFindFolder(short vRefNum,
OSType folderType, OSType folderType,
Boolean createFolder); Boolean createFolder);

View File

@@ -42,6 +42,7 @@ public:
virtual wxString GetResourcesDir() const; virtual wxString GetResourcesDir() const;
virtual wxString GetLocalizedResourcesDir(const wxChar *lang, virtual wxString GetLocalizedResourcesDir(const wxChar *lang,
ResourceCat category) const; ResourceCat category) const;
virtual wxString GetDocumentsDir() const;
protected: protected:
// this function can be called with any of CFBundleCopyXXXURL function // this function can be called with any of CFBundleCopyXXXURL function

View File

@@ -26,6 +26,7 @@ public:
virtual wxString GetUserDataDir() const; virtual wxString GetUserDataDir() const;
virtual wxString GetUserLocalDataDir() const; virtual wxString GetUserLocalDataDir() const;
virtual wxString GetPluginsDir() const; virtual wxString GetPluginsDir() const;
virtual wxString GetDocumentsDir() const;
protected: protected:
// get the path corresponding to the given standard CSIDL_XXX constant // get the path corresponding to the given standard CSIDL_XXX constant

View File

@@ -111,6 +111,12 @@ public:
return GetResourcesDir() + wxFILE_SEP_PATH + lang; 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 dtor for the base class
virtual ~wxStandardPathsBase(); virtual ~wxStandardPathsBase();
@@ -149,6 +155,7 @@ public:
virtual wxString GetLocalDataDir() const { return m_prefix; } virtual wxString GetLocalDataDir() const { return m_prefix; }
virtual wxString GetUserDataDir() const { return m_prefix; } virtual wxString GetUserDataDir() const { return m_prefix; }
virtual wxString GetPluginsDir() const { return m_prefix; } virtual wxString GetPluginsDir() const { return m_prefix; }
virtual wxString GetDocumentsDir() const { return m_prefix; }
private: private:
wxString m_prefix; wxString m_prefix;

View 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 (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):\t%s\n"), stdp.GetUserDataDir().c_str());
wxPrintf(_T("Data dir (user local):\t%s\n"), stdp.GetUserLocalDataDir().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("Plugins dir:\t\t%s\n"), stdp.GetPluginsDir().c_str());
wxPrintf(_T("Resources dir:\t\t%s\n"), stdp.GetResourcesDir().c_str()); wxPrintf(_T("Resources dir:\t\t%s\n"), stdp.GetResourcesDir().c_str());
wxPrintf(_T("Localized res. dir:\t%s\n"), wxPrintf(_T("Localized res. dir:\t%s\n"),

View File

@@ -73,6 +73,11 @@ wxString wxStandardPathsBase::GetUserLocalDataDir() const
return GetUserDataDir(); return GetUserDataDir();
} }
wxString wxStandardPathsBase::GetDocumentsDir() const
{
return wxFileName::GetHomeDir();
}
/* static */ /* static */
wxString wxStandardPathsBase::AppendAppName(const wxString& dir) wxString wxStandardPathsBase::AppendAppName(const wxString& dir)
{ {

View File

@@ -521,7 +521,7 @@ bool wxIsBusy()
#if wxUSE_BASE #if wxUSE_BASE
wxString wxMacFindFolder( short vol, wxString wxMacFindFolderNoSeparator( short vol,
OSType folderType, OSType folderType,
Boolean createFolder) Boolean createFolder)
{ {
@@ -529,11 +529,20 @@ wxString wxMacFindFolder( short vol,
wxString strDir ; wxString strDir ;
if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr) if ( FSFindFolder( vol, folderType, createFolder, &fsRef) == noErr)
strDir = wxMacFSRefToPath( &fsRef ) + wxFILE_SEP_PATH ; {
strDir = wxMacFSRefToPath( &fsRef );
}
return strDir ; return strDir ;
} }
wxString wxMacFindFolder( short vol,
OSType folderType,
Boolean createFolder)
{
return wxMacFindFolderNoSeparator(vol, folderType, createFolder) + wxFILE_SEP_PATH;
}
#endif // wxUSE_BASE #endif // wxUSE_BASE
#if wxUSE_GUI #if wxUSE_GUI

View File

@@ -372,7 +372,7 @@ bool wxIsBusy()
#if wxUSE_BASE #if wxUSE_BASE
wxString wxMacFindFolder( short vol, wxString wxMacFindFolderNoSeparator( short vol,
OSType folderType, OSType folderType,
Boolean createFolder) Boolean createFolder)
{ {
@@ -385,12 +385,19 @@ wxString wxMacFindFolder( short vol,
FSSpec file ; FSSpec file ;
if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr ) if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
{ {
strDir = wxMacFSSpec2MacFilename( &file ) + wxFILE_SEP_PATH ; strDir = wxMacFSSpec2MacFilename( &file );
} }
} }
return strDir ; return strDir ;
} }
wxString wxMacFindFolder( short vol,
OSType folderType,
Boolean createFolder)
{
return wxMacFindFolderNoSeparator(vol, folderType, createFolder) + wxFILE_SEP_PATH;
}
#endif // wxUSE_BASE #endif // wxUSE_BASE
#if wxUSE_GUI #if wxUSE_GUI

View File

@@ -31,6 +31,7 @@
#include "wx/mac/private.h" #include "wx/mac/private.h"
#endif #endif
#include "wx/mac/corefoundation/cfstring.h" #include "wx/mac/corefoundation/cfstring.h"
#include "wx/mac/private.h"
#if defined(__DARWIN__) #if defined(__DARWIN__)
#include <CoreFoundation/CFBundle.h> #include <CoreFoundation/CFBundle.h>
@@ -106,6 +107,20 @@ wxString wxStandardPathsCF::GetFromFunc(wxCFURLRef (*func)(wxCFBundleRef)) const
return ret; return ret;
} }
wxString wxStandardPathsCF::GetDocumentsDir() const
{
return wxMacFindFolderNoSeparator
(
#if TARGET_API_MAC_OSX
kUserDomain,
#else
kOnSystemDisk,
#endif
kDocumentsFolderType,
kCreateFolder
);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxStandardPathsCF public API // wxStandardPathsCF public API
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -68,6 +68,10 @@ static const wxChar *TRACE_MASK = _T("stdpaths");
#define CSIDL_PROGRAM_FILES 0x0026 #define CSIDL_PROGRAM_FILES 0x0026
#endif #endif
#ifndef CSIDL_PERSONAL
#define CSIDL_PERSONAL 0x0005
#endif
#ifndef SHGFP_TYPE_CURRENT #ifndef SHGFP_TYPE_CURRENT
#define SHGFP_TYPE_CURRENT 0 #define SHGFP_TYPE_CURRENT 0
#endif #endif
@@ -75,7 +79,6 @@ static const wxChar *TRACE_MASK = _T("stdpaths");
#ifndef SHGFP_TYPE_DEFAULT #ifndef SHGFP_TYPE_DEFAULT
#define SHGFP_TYPE_DEFAULT 1 #define SHGFP_TYPE_DEFAULT 1
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// module globals // module globals
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -262,6 +265,11 @@ wxString wxStandardPaths::GetAppDir()
return fn.GetPath(); return fn.GetPath();
} }
wxString wxStandardPaths::GetDocumentsDir() const
{
return DoGetDirectory(CSIDL_PERSONAL);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// public functions // public functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------