diff options
author | Jacek Antonelli | 2009-04-30 13:04:20 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-30 13:07:16 -0500 |
commit | ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch) | |
tree | 8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llvfs/lldir_solaris.cpp | |
parent | Second Life viewer sources 1.22.11 (diff) | |
download | meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2 meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz |
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/llvfs/lldir_solaris.cpp')
-rw-r--r-- | linden/indra/llvfs/lldir_solaris.cpp | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/linden/indra/llvfs/lldir_solaris.cpp b/linden/indra/llvfs/lldir_solaris.cpp index adbe747..9553d92 100644 --- a/linden/indra/llvfs/lldir_solaris.cpp +++ b/linden/indra/llvfs/lldir_solaris.cpp | |||
@@ -17,7 +17,8 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -36,14 +37,13 @@ | |||
36 | #include "llrand.h" | 37 | #include "llrand.h" |
37 | #include <sys/types.h> | 38 | #include <sys/types.h> |
38 | #include <sys/stat.h> | 39 | #include <sys/stat.h> |
39 | #include <fcntl.h> | ||
40 | #include <sys/param.h> | ||
41 | #include <unistd.h> | 40 | #include <unistd.h> |
42 | #include <glob.h> | 41 | #include <glob.h> |
43 | #include <pwd.h> | 42 | #include <pwd.h> |
44 | #include <sys/utsname.h> | 43 | #include <sys/utsname.h> |
45 | #define _STRUCTURED_PROC 1 | 44 | #define _STRUCTURED_PROC 1 |
46 | #include <sys/procfs.h> | 45 | #include <sys/procfs.h> |
46 | #include <fcntl.h> | ||
47 | 47 | ||
48 | static std::string getCurrentUserHome(char* fallback) | 48 | static std::string getCurrentUserHome(char* fallback) |
49 | { | 49 | { |
@@ -82,7 +82,16 @@ LLDir_Solaris::LLDir_Solaris() | |||
82 | mDirp = NULL; | 82 | mDirp = NULL; |
83 | 83 | ||
84 | char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ | 84 | char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ |
85 | getcwd(tmp_str, LL_MAX_PATH); | 85 | if (getcwd(tmp_str, LL_MAX_PATH) == NULL) |
86 | { | ||
87 | strcpy(tmp_str, "/tmp"); | ||
88 | llwarns << "Could not get current directory; changing to " | ||
89 | << tmp_str << llendl; | ||
90 | if (chdir(tmp_str) == -1) | ||
91 | { | ||
92 | llerrs << "Could not change directory to " << tmp_str << llendl; | ||
93 | } | ||
94 | } | ||
86 | 95 | ||
87 | mExecutableFilename = ""; | 96 | mExecutableFilename = ""; |
88 | mExecutablePathAndName = ""; | 97 | mExecutablePathAndName = ""; |
@@ -121,20 +130,35 @@ LLDir_Solaris::LLDir_Solaris() | |||
121 | return; | 130 | return; |
122 | } | 131 | } |
123 | 132 | ||
133 | char *p = execpath; // nuke trash in link, if any exists | ||
134 | int i = 0; | ||
135 | while(*p != NULL && ++i < LL_MAX_PATH && isprint((int)(*p++))); | ||
136 | *p = NULL; | ||
137 | |||
124 | mExecutablePathAndName = strdup(execpath); | 138 | mExecutablePathAndName = strdup(execpath); |
125 | llinfos << "mExecutablePathAndName = [" << mExecutablePathAndName << "]" << llendl; | 139 | llinfos << "mExecutablePathAndName = [" << mExecutablePathAndName << "]" << llendl; |
126 | 140 | ||
141 | //NOTE: Why force people to cd into the package directory? | ||
142 | // Look for SECONDLIFE env variable and use it, if set. | ||
143 | |||
144 | char *dcf = getenv("SECONDLIFE"); | ||
145 | if(dcf != NULL){ | ||
146 | (void)strcpy(path, dcf); | ||
147 | (void)strcat(path, "/bin"); //NOTE: make sure we point at the bin | ||
148 | mExecutableDir = strdup(path); | ||
149 | }else{ | ||
127 | // plunk a null at last '/' to get exec dir | 150 | // plunk a null at last '/' to get exec dir |
128 | char *s = execpath + strlen(execpath) -1; | 151 | char *s = execpath + strlen(execpath) -1; |
129 | while(*s != '/' && s != execpath){ | 152 | while(*s != '/' && s != execpath){ |
130 | --s; | 153 | --s; |
131 | } | 154 | } |
132 | 155 | ||
133 | if(s != execpath){ | 156 | if(s != execpath){ |
134 | *s = (char)NULL; | 157 | *s = (char)NULL; |
135 | 158 | ||
136 | mExecutableDir = strdup(execpath); | 159 | mExecutableDir = strdup(execpath); |
137 | llinfos << "mExecutableDir = [" << mExecutableDir << "]" << llendl; | 160 | llinfos << "mExecutableDir = [" << mExecutableDir << "]" << llendl; |
161 | } | ||
138 | } | 162 | } |
139 | 163 | ||
140 | // *TODO: don't use /tmp, use $HOME/.secondlife/tmp or something. | 164 | // *TODO: don't use /tmp, use $HOME/.secondlife/tmp or something. |
@@ -354,12 +378,16 @@ void LLDir_Solaris::getRandomFileInDir(const std::string &dirname, const std::st | |||
354 | std::string LLDir_Solaris::getCurPath() | 378 | std::string LLDir_Solaris::getCurPath() |
355 | { | 379 | { |
356 | char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ | 380 | char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ |
357 | getcwd(tmp_str, LL_MAX_PATH); | 381 | if (getcwd(tmp_str, LL_MAX_PATH) == NULL) |
382 | { | ||
383 | llwarns << "Could not get current directory" << llendl; | ||
384 | tmp_str[0] = '\0'; | ||
385 | } | ||
358 | return tmp_str; | 386 | return tmp_str; |
359 | } | 387 | } |
360 | 388 | ||
361 | 389 | ||
362 | BOOL LLDir_Solaris::fileExists(const std::string &filename) | 390 | BOOL LLDir_Solaris::fileExists(const std::string &filename) const |
363 | { | 391 | { |
364 | struct stat stat_data; | 392 | struct stat stat_data; |
365 | // Check the age of the file | 393 | // Check the age of the file |