MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / gotoWebPage

Function gotoWebPage

Engine/source/console/consoleFunctions.cpp:2133–2164  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2131
2132//-----------------------------------------------------------------------------
2133void gotoWebPage(const char* address)
2134{
2135 // If there's a protocol prefix in the address, just invoke
2136 // the browser on the given address.
2137
2138 char* protocolSep = dStrstr(address, "://");
2139 if (protocolSep != NULL)
2140 {
2141 Platform::openWebBrowser(address);
2142 return;
2143 }
2144
2145 // If we don't see a protocol seperator, then we know that some bullethead
2146 // sent us a bad url. We'll first check to see if a file inside the sandbox
2147 // with that name exists, then we'll just glom "http://" onto the front of
2148 // the bogus url, and hope for the best.
2149
2150 String addr;
2151 if (Torque::FS::IsFile(address) || Torque::FS::IsDirectory(address))
2152 {
2153#ifdef TORQUE2D_TOOLS_FIXME
2154 addr = String::ToString("file://%s", address);
2155#else
2156 addr = String::ToString("file://%s/%s", Platform::getCurrentDirectory(), address);
2157#endif
2158 }
2159 else
2160 addr = String::ToString("http://%s", address);
2161
2162 Platform::openWebBrowser(addr);
2163 return;
2164}
2165
2166DefineEngineFunction( gotoWebPage, void, ( const char* address ),,
2167 "Open the given URL or file in the user's web browser.\n\n"

Callers 2

getDocsURLFunction · 0.85

Calls 3

dStrstrFunction · 0.85
IsFileFunction · 0.85
IsDirectoryFunction · 0.85

Tested by

no test coverage detected