mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Use realpath to resolve paths
This commit is contained in:
@@ -96,12 +96,19 @@ int main(int argc, char *argv[]) {
|
||||
window_info.SetAsChild(vbox);
|
||||
|
||||
std::string path;
|
||||
path.append("file://");
|
||||
path.append(szPath);
|
||||
path.append("/../index.html");
|
||||
char* realPath;
|
||||
realPath = realpath(path.c_str(), NULL);
|
||||
if (realPath == NULL)
|
||||
return -1;
|
||||
|
||||
std::string resolved("file://");
|
||||
resolved.append(realPath);
|
||||
free(realPath);
|
||||
|
||||
CefBrowser::CreateBrowserSync(window_info,
|
||||
static_cast<CefRefPtr<CefClient> >(g_handler), path,
|
||||
static_cast<CefRefPtr<CefClient> >(g_handler), resolved,
|
||||
browserSettings);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(window), vbox);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "include/cef_frame.h"
|
||||
#include "cefclient.h"
|
||||
#include "native_handler.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
ClientHandler::ClientHandler() :
|
||||
m_MainHwnd(NULL), m_BrowserHwnd(NULL), m_bFormElementHasFocus(false) {
|
||||
@@ -90,9 +91,18 @@ void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefV8Value> atom = CefV8Value::CreateObject(NULL, NULL);
|
||||
global->SetValue("atom", atom, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
CefRefPtr<CefV8Value> loadPath = CefV8Value::CreateString(
|
||||
AppPath() + "/..");
|
||||
atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
std::string relativePath(AppPath());
|
||||
relativePath.append("/..");
|
||||
char* realLoadPath;
|
||||
realLoadPath = realpath(relativePath.c_str(), NULL);
|
||||
if (realLoadPath != NULL) {
|
||||
std::string resolvedLoadPath(realLoadPath);
|
||||
free(realLoadPath);
|
||||
|
||||
CefRefPtr<CefV8Value> loadPath = CefV8Value::CreateString(
|
||||
resolvedLoadPath);
|
||||
atom->SetValue("loadPath", loadPath, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
|
||||
CefRefPtr<CefV8Value> bootstrapScript = CefV8Value::CreateString(
|
||||
"single-window-bootstrap");
|
||||
|
||||
Reference in New Issue
Block a user