MCPcopy Create free account
hub / github.com/audacity/audacity / InitializePathList

Method InitializePathList

libraries/lib-files/PathList.cpp:38–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36#endif
37
38void FileNames::InitializePathList()
39{
40 const auto programPath = PlatformCompatibility::GetExecutablePath();
41
42 //
43 // Paths: set search path and temp dir path
44 //
45 FilePaths audacityPathList;
46 auto &standardPaths = wxStandardPaths::Get();
47
48#ifdef __WXGTK__
49 const auto portablePrefix = wxPathOnly(wxPathOnly(programPath));
50
51 // Make sure install prefix is set so wxStandardPath resolves paths properly
52 if (wxDirExists(portablePrefix + L"/share/audacity")) {
53 // use prefix relative to executable location to make Audacity portable
54 standardPaths.SetInstallPrefix(portablePrefix);
55 } else {
56 // fallback to hard-coded prefix set during configuration
57 standardPaths.SetInstallPrefix(wxT(INSTALL_PREFIX));
58 }
59 wxString installPrefix = standardPaths.GetInstallPrefix();
60
61 /* Search path (for plug-ins, translations etc) is (in this order):
62 * The AUDACITY_PATH environment variable
63 * The current directory
64 * The user's "~/.audacity-data" or "Portable Settings" directory
65 * The user's "~/.audacity-files" directory
66 * The "share" and "share/doc" directories in their install path */
67 wxString home = wxGetHomeDir();
68
69 wxString envTempDir = wxGetenv(wxT("TMPDIR"));
70 if (!envTempDir.empty()) {
71 /* On Unix systems, the environment variable TMPDIR may point to
72 an unusual path when /tmp and /var/tmp are not desirable. */
73 TempDirectory::SetDefaultTempDir( wxString::Format(
74 wxT("%s/audacity-%s"), envTempDir, wxGetUserId() ) );
75 } else {
76 /* On Unix systems, the default temp dir is in /var/tmp. */
77 TempDirectory::SetDefaultTempDir( wxString::Format(
78 wxT("/var/tmp/audacity-%s"), wxGetUserId() ) );
79 }
80
81 wxString pathVar = wxGetenv(wxT("AUDACITY_PATH"));
82
83 if (!pathVar.empty())
84 FileNames::AddMultiPathsToPathList(pathVar, audacityPathList);
85 FileNames::AddUniquePathToPathList(::wxGetCwd(), audacityPathList);
86
87 const auto progPath = wxPathOnly(programPath);
88
89 FileNames::AddUniquePathToPathList(progPath, audacityPathList);
90 // Add the path to modules:
91 FileNames::AddUniquePathToPathList(progPath + L"/lib/audacity", audacityPathList);
92
93#if !defined(__WXMSW__)
94 // On Unix systems, the common directory structure is
95 // .../bin

Callers

nothing calls this directly

Calls 7

GetFunction · 0.85
GetLibraryPathFunction · 0.85
moveFunction · 0.85
emptyMethod · 0.45
IsEmptyMethod · 0.45
GetPathMethod · 0.45
GetUserLocalDataDirMethod · 0.45

Tested by

no test coverage detected