Ghost/Linux: Avoid error print if special directory can't be determined
The function is supposed to fail gracefully if there is some error. That includes not being able to find `xdg-user-dir`. So don't let the error be printed to the console, it's misleading/annoying. From what I can tell we'll detect that problem fine and return NULL then.
This commit is contained in:
parent
a8da70f70a
commit
9d15226383
|
@ -142,7 +142,8 @@ const GHOST_TUns8 *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDi
|
|||
}
|
||||
|
||||
static string path = "";
|
||||
string command = string("xdg-user-dir ") + type_str;
|
||||
/* Pipe stderr to /dev/null to avoid error prints. We will fail gracefully still. */
|
||||
string command = string("xdg-user-dir ") + type_str + " 2> /dev/null";
|
||||
|
||||
FILE *fstream = popen(command.c_str(), "r");
|
||||
if (fstream == NULL) {
|
||||
|
@ -163,7 +164,7 @@ const GHOST_TUns8 *GHOST_SystemPathsUnix::getUserSpecialDir(GHOST_TUserSpecialDi
|
|||
}
|
||||
|
||||
path = path_stream.str();
|
||||
return (const GHOST_TUns8 *)path.c_str();
|
||||
return path[0] ? (const GHOST_TUns8 *)path.c_str() : NULL;
|
||||
}
|
||||
|
||||
const GHOST_TUns8 *GHOST_SystemPathsUnix::getBinaryDir() const
|
||||
|
|
Loading…
Reference in New Issue