Add platform.cpp file for Node
This commit is contained in:
parent
c803efd01b
commit
0b1a686f60
|
@ -43,7 +43,6 @@
|
|||
F60102E01CBB96D900EC01BA /* realm_coordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02F59EDB1C88F2BA007F774C /* realm_coordinator.cpp */; };
|
||||
F60102E11CBB96DD00EC01BA /* transact_log_handler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02F59EDD1C88F2BB007F774C /* transact_log_handler.cpp */; };
|
||||
F60102E51CBBB19700EC01BA /* node_object_accessor.hpp in Headers */ = {isa = PBXBuildFile; fileRef = F60102E31CBBB19700EC01BA /* node_object_accessor.hpp */; };
|
||||
F60102E91CBCAEC500EC01BA /* platform.mm in Sources */ = {isa = PBXBuildFile; fileRef = 029048381C042A8F00ABDED4 /* platform.mm */; };
|
||||
F60102EA1CBCAFC300EC01BA /* node_dummy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6267BCA1CADC49200AC36B1 /* node_dummy.cpp */; };
|
||||
F61378791C18EAC5008BFC51 /* js in Resources */ = {isa = PBXBuildFile; fileRef = F61378781C18EAAC008BFC51 /* js */; };
|
||||
F620F0581CB766DA0082977B /* node_init.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F620F0571CB766DA0082977B /* node_init.cpp */; };
|
||||
|
@ -66,6 +65,7 @@
|
|||
F63FF3251C1642BB00B3B8E0 /* GCDWebServerErrorResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = F63FF3161C1642BB00B3B8E0 /* GCDWebServerErrorResponse.m */; };
|
||||
F63FF3261C1642BB00B3B8E0 /* GCDWebServerFileResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = F63FF3181C1642BB00B3B8E0 /* GCDWebServerFileResponse.m */; };
|
||||
F63FF3271C1642BB00B3B8E0 /* GCDWebServerStreamedResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = F63FF31A1C1642BB00B3B8E0 /* GCDWebServerStreamedResponse.m */; };
|
||||
F674784A1CC81F1900F9273C /* platform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F67478481CC81F1300F9273C /* platform.cpp */; };
|
||||
F68A278C1BC2722A0063D40A /* RJSModuleLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = F68A278B1BC2722A0063D40A /* RJSModuleLoader.m */; };
|
||||
F6BCCFE21C8380A400FE31AE /* lib in Resources */ = {isa = PBXBuildFile; fileRef = F6BCCFDF1C83809A00FE31AE /* lib */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
@ -207,6 +207,7 @@
|
|||
F63FF32C1C16432E00B3B8E0 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
|
||||
F63FF32E1C16433900B3B8E0 /* libxml2.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libxml2.tbd; path = usr/lib/libxml2.tbd; sourceTree = SDKROOT; };
|
||||
F63FF3301C16434400B3B8E0 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
|
||||
F67478481CC81F1300F9273C /* platform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = platform.cpp; sourceTree = "<group>"; };
|
||||
F6874A351CAC792D00EEEE36 /* node_types.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = node_types.hpp; sourceTree = "<group>"; };
|
||||
F6874A3E1CACA5A900EEEE36 /* js_types.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = js_types.hpp; sourceTree = "<group>"; };
|
||||
F68A278A1BC2722A0063D40A /* RJSModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RJSModuleLoader.h; path = ios/RJSModuleLoader.h; sourceTree = "<group>"; };
|
||||
|
@ -404,6 +405,7 @@
|
|||
F60103071CC4B3DF00EC01BA /* node_protected.hpp */,
|
||||
F60103151CC4CCFD00EC01BA /* node_return_value.hpp */,
|
||||
F60102E31CBBB19700EC01BA /* node_object_accessor.hpp */,
|
||||
F67478481CC81F1300F9273C /* platform.cpp */,
|
||||
);
|
||||
name = Node;
|
||||
path = node;
|
||||
|
@ -702,9 +704,9 @@
|
|||
F60102EA1CBCAFC300EC01BA /* node_dummy.cpp in Sources */,
|
||||
F60102D81CBB96BD00EC01BA /* results.cpp in Sources */,
|
||||
F60102DE1CBB96CF00EC01BA /* weak_realm_notifier.cpp in Sources */,
|
||||
F674784A1CC81F1900F9273C /* platform.cpp in Sources */,
|
||||
F620F0581CB766DA0082977B /* node_init.cpp in Sources */,
|
||||
F60102D91CBB96C100EC01BA /* schema.cpp in Sources */,
|
||||
F60102E91CBCAEC500EC01BA /* platform.mm in Sources */,
|
||||
F60102DF1CBB96D300EC01BA /* async_query.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -1003,6 +1005,7 @@
|
|||
EXECUTABLE_PREFIX = lib;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"REALM_PLATFORM_NODE=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
|
@ -1016,6 +1019,7 @@
|
|||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lrealm",
|
||||
"-luv",
|
||||
"-lv8",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -1029,6 +1033,10 @@
|
|||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 0.12.0;
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"REALM_PLATFORM_NODE=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../../node_modules/nan",
|
||||
|
@ -1040,6 +1048,7 @@
|
|||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lrealm",
|
||||
"-luv",
|
||||
"-lv8",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
@ -1053,6 +1062,10 @@
|
|||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 0.12.0;
|
||||
EXECUTABLE_PREFIX = lib;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"REALM_PLATFORM_NODE=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(SRCROOT)/../../node_modules/nan",
|
||||
|
@ -1064,6 +1077,7 @@
|
|||
);
|
||||
OTHER_LDFLAGS = (
|
||||
"-lrealm",
|
||||
"-luv",
|
||||
"-lv8",
|
||||
);
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
|
|
|
@ -192,7 +192,7 @@ class Realm {
|
|||
}
|
||||
|
||||
static std::string normalize_path(std::string path) {
|
||||
if (path.size() && path[0] != '/') {
|
||||
if (path.size() && path[0] != '/' && path[0] != '.') {
|
||||
return default_realm_file_directory() + "/" + path;
|
||||
}
|
||||
return path;
|
||||
|
@ -576,7 +576,7 @@ template<typename T>
|
|||
void Realm<T>::add_listener(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 2);
|
||||
|
||||
__unused std::string name = validated_notification_name(ctx, arguments[0]);
|
||||
validated_notification_name(ctx, arguments[0]);
|
||||
auto callback = Value::validated_to_function(ctx, arguments[1]);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
|
@ -587,7 +587,7 @@ template<typename T>
|
|||
void Realm<T>::remove_listener(ContextType ctx, ObjectType this_object, size_t argc, const ValueType arguments[], ReturnValue &return_value) {
|
||||
validate_argument_count(argc, 2);
|
||||
|
||||
__unused std::string name = validated_notification_name(ctx, arguments[0]);
|
||||
validated_notification_name(ctx, arguments[0]);
|
||||
auto callback = Value::validated_to_function(ctx, arguments[1]);
|
||||
|
||||
SharedRealm realm = *get_internal<T, RealmClass<T>>(this_object);
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
"target_name": "realm",
|
||||
"sources": [
|
||||
"node_init.cpp",
|
||||
"platform.cpp",
|
||||
"../js_realm.cpp",
|
||||
"../ios/platform.mm",
|
||||
"../object-store/src/index_set.cpp",
|
||||
"../object-store/src/list.cpp",
|
||||
"../object-store/src/object_schema.cpp",
|
||||
|
@ -34,15 +34,18 @@
|
|||
"library_dirs": [
|
||||
"$(srcdir)/../../core"
|
||||
],
|
||||
"defines": ["REALM_HAVE_CONFIG"],
|
||||
"defines": [
|
||||
"REALM_HAVE_CONFIG",
|
||||
"REALM_PLATFORM_NODE=1"
|
||||
],
|
||||
"cflags_cc": ["-fexceptions", "-frtti", "-std=c++14"],
|
||||
"ldflags": ["-lrealm"],
|
||||
"libraries": ["-lrealm"],
|
||||
"xcode_settings": {
|
||||
"CLANG_CXX_LANGUAGE_STANDARD": "c++14",
|
||||
"CLANG_CXX_LIBRARY": "libc++",
|
||||
"MACOSX_DEPLOYMENT_TARGET": "10.8",
|
||||
"OTHER_CPLUSPLUSFLAGS": ["-fexceptions", "-frtti"],
|
||||
"OTHER_LDFLAGS": ["-lrealm", "-framework", "Foundation"]
|
||||
"OTHER_LDFLAGS": ["-framework", "Foundation"]
|
||||
},
|
||||
"configurations": {
|
||||
"Debug": {
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2016 Realm Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <system_error>
|
||||
|
||||
#include "../platform.hpp"
|
||||
|
||||
namespace realm {
|
||||
|
||||
std::string default_realm_file_directory()
|
||||
{
|
||||
// Relative paths should always be relative to the current working directory.
|
||||
return ".";
|
||||
}
|
||||
|
||||
void ensure_directory_exists_for_file(const std::string &file_path)
|
||||
{
|
||||
size_t pos = 0;
|
||||
|
||||
while ((pos = file_path.find_first_of('/', pos)) != std::string::npos) {
|
||||
// Skip for leading slash.
|
||||
if (pos == 0) {
|
||||
pos++;
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string dir_path = file_path.substr(0, pos++);
|
||||
if (mkdir(dir_path.c_str(), 0755) != 0 && errno != EEXIST) {
|
||||
throw std::system_error(errno, std::system_category());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void copy_bundled_realm_files()
|
||||
{
|
||||
throw std::runtime_error("Realm for Node does not support this method.");
|
||||
}
|
||||
|
||||
void remove_realm_files_from_directory(const std::string &dir_path)
|
||||
{
|
||||
DIR *dir = opendir(dir_path.c_str());
|
||||
if (!dir) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (struct dirent *entry = readdir(dir)) {
|
||||
if (strstr(entry->d_name, ".realm")) {
|
||||
// Intentionally not complaining if there was an error.
|
||||
unlink(entry->d_name);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
} // realm
|
Loading…
Reference in New Issue