Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1831)

Unified Diff: runtime/bin/file.cc

Issue 14907002: dart:io | Implement asynchronous versions of FileSystemEntity methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add implementation of FileSystemEntity.type, and refactor error handling. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_system_entity_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index 5fb1bcdc1b72ddc6688d75ed98cdbda92b8d3376..bc8ca4cbcd4645fb4ee5981c72c37960001acfab 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -1089,6 +1089,39 @@ static CObject* FileLinkTargetRequest(const CObjectArray& request) {
}
+static CObject* FileTypeRequest(const CObjectArray& request) {
+ if (request.Length() == 3 &&
+ request[1]->IsString() &&
+ request[2]->IsBool()) {
+ CObjectString path(request[1]);
+ CObjectBool follow_links(request[2]);
+ File::Type type = File::GetType(path.CString(), follow_links.Value());
+ return new CObjectInt32(CObject::NewInt32(type));
+ }
+ return CObject::IllegalArgumentError();
+}
+
+
+static CObject* FileIdenticalRequest(const CObjectArray& request) {
+ if (request.Length() == 3 &&
+ request[1]->IsString() &&
+ request[2]->IsString()) {
+ CObjectString path1(request[1]);
+ CObjectString path2(request[2]);
+ File::Identical result = File::AreIdentical(path1.CString(),
+ path2.CString());
+ if (result == File::kError) {
+ return CObject::NewOSError();
+ } else if (result == File::kIdentical) {
+ return CObject::True();
+ } else {
+ return CObject::False();
+ }
+ }
+ return CObject::IllegalArgumentError();
+}
+
+
static void FileService(Dart_Port dest_port_id,
Dart_Port reply_port_id,
Dart_CObject* message) {
@@ -1164,6 +1197,12 @@ static void FileService(Dart_Port dest_port_id,
case File::kLinkTargetRequest:
response = FileLinkTargetRequest(request);
break;
+ case File::kTypeRequest:
+ response = FileTypeRequest(request);
+ break;
+ case File::kIdenticalRequest:
+ response = FileIdenticalRequest(request);
+ break;
default:
UNREACHABLE();
}
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_system_entity_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698