| 4217 | } |
| 4218 | |
| 4219 | static std::string getShellEnv( const std::string& env, const std::string& defShell = "" ) { |
| 4220 | std::string shell = defShell.empty() ? Sys::which( getDefaultShell() ) : defShell; |
| 4221 | Process process; |
| 4222 | if ( process.create( shell, "-l -c env", Process::getDefaultOptions() ) ) { |
| 4223 | size_t envLen = env.size(); |
| 4224 | std::string buf( 32 * 1024, '\0' ); |
| 4225 | process.readAllStdOut( buf ); |
| 4226 | auto pathPos = buf.find( "\n" + env + "=" ); |
| 4227 | bool startsWithPath = false; |
| 4228 | if ( pathPos == std::string::npos && buf.substr( 0, envLen + 1 ) == env + "=" ) |
| 4229 | startsWithPath = true; |
| 4230 | if ( pathPos != std::string::npos || startsWithPath ) { |
| 4231 | pathPos += startsWithPath ? envLen + 1 : envLen + 2; // Remove \n + env + "=" |
| 4232 | auto endPathPos = buf.find_first_of( "\r\n", pathPos ); |
| 4233 | if ( endPathPos != std::string::npos ) { |
| 4234 | size_t len = endPathPos - pathPos; |
| 4235 | return buf.substr( pathPos, len ); |
| 4236 | } else { |
| 4237 | return buf.substr( pathPos ); |
| 4238 | } |
| 4239 | } |
| 4240 | } |
| 4241 | return ""; |
| 4242 | } |
| 4243 | #endif |
| 4244 | |
| 4245 | FontTrueType* App::loadFont( const std::string& name, std::string fontPath, |
no test coverage detected