Index: src/FileSystemJsObject.cpp |
=================================================================== |
--- a/src/FileSystemJsObject.cpp |
+++ b/src/FileSystemJsObject.cpp |
@@ -184,6 +184,7 @@ |
std::string path; |
}; |
+ |
class StatThread : public IoThread |
{ |
public: |
@@ -312,8 +313,24 @@ |
statThread->Start(); |
return v8::Undefined(); |
} |
+ |
+ v8::Handle<v8::Value> ResolveCallback(const v8::Arguments& arguments) |
+ { |
+ AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::FromArguments(arguments); |
+ AdblockPlus::JsValueList converted = jsEngine->ConvertArguments(arguments); |
+ |
+ if (converted.size() != 1) |
+ return v8::ThrowException(v8::String::New( |
+ "_fileSystem.resolve requires 1 parameter")); |
+ |
+ std::string resolved = jsEngine->GetFileSystem()->Resolve(converted[0]->AsString()); |
+ |
+ return v8::String::New(resolved.c_str(), resolved.length()); |
Wladimir Palant
2013/04/24 09:17:35
Please use Utils::ToV8String() here.
|
+ } |
+ |
} |
+ |
JsValuePtr FileSystemJsObject::Setup(JsEnginePtr jsEngine, JsValuePtr obj) |
{ |
obj->SetProperty("read", jsEngine->NewCallback(::ReadCallback)); |
@@ -321,5 +338,6 @@ |
obj->SetProperty("move", jsEngine->NewCallback(::MoveCallback)); |
obj->SetProperty("remove", jsEngine->NewCallback(::RemoveCallback)); |
obj->SetProperty("stat", jsEngine->NewCallback(::StatCallback)); |
+ obj->SetProperty("resolve", jsEngine->NewCallback(::ResolveCallback)); |
return obj; |
} |