Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/FileSystemJsObject.cpp

Issue 10369004: File system path resolving (Closed)
Patch Set: Created April 24, 2013, 2:10 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/DefaultFileSystem.cpp ('K') | « src/DefaultFileSystem.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« src/DefaultFileSystem.cpp ('K') | « src/DefaultFileSystem.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld