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

Side by Side Diff: runtime/bin/file.cc

Issue 12850010: Add FileSystemEntity.identical, to test if two file system objects are the same. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Improve posix versions Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/file.h" 5 #include "bin/file.h"
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/dartutils.h" 8 #include "bin/dartutils.h"
9 #include "bin/io_buffer.h" 9 #include "bin/io_buffer.h"
10 #include "bin/thread.h" 10 #include "bin/thread.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 Dart_EnterScope(); 548 Dart_EnterScope();
549 if (Dart_IsString(Dart_GetNativeArgument(args, 0)) && 549 if (Dart_IsString(Dart_GetNativeArgument(args, 0)) &&
550 Dart_IsBoolean(Dart_GetNativeArgument(args, 1))) { 550 Dart_IsBoolean(Dart_GetNativeArgument(args, 1))) {
551 const char* str = 551 const char* str =
552 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); 552 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
553 bool follow_links = 553 bool follow_links =
554 DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 1)); 554 DartUtils::GetBooleanValue(Dart_GetNativeArgument(args, 1));
555 File::Type type = File::GetType(str, follow_links); 555 File::Type type = File::GetType(str, follow_links);
556 Dart_SetReturnValue(args, Dart_NewInteger(static_cast<int>(type))); 556 Dart_SetReturnValue(args, Dart_NewInteger(static_cast<int>(type)));
557 } else { 557 } else {
558 OSError os_error(-1, "Invalid argument", OSError::kUnknown); 558 Dart_Handle err = DartUtils::NewDartArgumentError(
559 Dart_Handle err = DartUtils::NewDartOSError(&os_error); 559 "Non-string argument to FileSystemEntity.type");
560 if (Dart_IsError(err)) Dart_PropagateError(err); 560 if (Dart_IsError(err)) Dart_PropagateError(err);
561 Dart_SetReturnValue(args, err); 561 Dart_SetReturnValue(args, err);
562 } 562 }
563 Dart_ExitScope();
564 }
565
566
567 void FUNCTION_NAME(File_AreIdentical)(Dart_NativeArguments args) {
568 Dart_EnterScope();
569 if (Dart_IsString(Dart_GetNativeArgument(args, 0)) &&
570 Dart_IsString(Dart_GetNativeArgument(args, 1))) {
571 const char* file_1 =
572 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
573 const char* file_2 =
574 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 1));
575 File::Identical result = File::AreIdentical(file_1, file_2);
576 if (result == File::kError) {
577 Dart_Handle err = DartUtils::NewDartOSError();
578 if (Dart_IsError(err)) Dart_PropagateError(err);
579 Dart_SetReturnValue(args, err);
580 } else {
581 Dart_SetReturnValue(args, Dart_NewBoolean(result == File::kIdentical));
582 }
583 } else {
584 Dart_Handle err = DartUtils::NewDartArgumentError(
585 "Non-string argument to FileSystemEntity.identical");
586 if (Dart_IsError(err)) Dart_PropagateError(err);
587 Dart_SetReturnValue(args, err);
588 }
563 Dart_ExitScope(); 589 Dart_ExitScope();
564 } 590 }
565 591
566 592
567 static int64_t CObjectInt32OrInt64ToInt64(CObject* cobject) { 593 static int64_t CObjectInt32OrInt64ToInt64(CObject* cobject) {
568 ASSERT(cobject->IsInt32OrInt64()); 594 ASSERT(cobject->IsInt32OrInt64());
569 int64_t result; 595 int64_t result;
570 if (cobject->IsInt32()) { 596 if (cobject->IsInt32()) {
571 CObjectInt32 value(cobject); 597 CObjectInt32 value(cobject);
572 result = value.Value(); 598 result = value.Value();
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 Dart_EnterScope(); 1082 Dart_EnterScope();
1057 Dart_SetReturnValue(args, Dart_Null()); 1083 Dart_SetReturnValue(args, Dart_Null());
1058 Dart_Port service_port = File::GetServicePort(); 1084 Dart_Port service_port = File::GetServicePort();
1059 if (service_port != ILLEGAL_PORT) { 1085 if (service_port != ILLEGAL_PORT) {
1060 // Return a send port for the service port. 1086 // Return a send port for the service port.
1061 Dart_Handle send_port = Dart_NewSendPort(service_port); 1087 Dart_Handle send_port = Dart_NewSendPort(service_port);
1062 Dart_SetReturnValue(args, send_port); 1088 Dart_SetReturnValue(args, send_port);
1063 } 1089 }
1064 Dart_ExitScope(); 1090 Dart_ExitScope();
1065 } 1091 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698