[ VM ] Addressed additional comments from CL 56461.

Change-Id: I396a4e1038ccc7ae4f504d817ee6790aeb8d2003
Reviewed-on: https://dart-review.googlesource.com/56620
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
diff --git a/runtime/bin/directory.cc b/runtime/bin/directory.cc
index 4f89b2d..de20ad9 100644
--- a/runtime/bin/directory.cc
+++ b/runtime/bin/directory.cc
@@ -66,7 +66,7 @@
     ASSERT(data.type() == Dart_TypedData_kUint8);
     const char* name = data.GetCString();
     result = Directory::Exists(namespc, name);
-    if ((result != Directory::DOES_NOT_EXIST) ||
+    if ((result != Directory::DOES_NOT_EXIST) &&
         (result != Directory::EXISTS)) {
       // Errors must be caught before TypedDataScope data is destroyed.
       os_error.Reload();
@@ -499,7 +499,7 @@
   // constructor. This avoids/delays interpreting the UTF-8 bytes in dir_name.
   // Later, client code may either choose to access FileSystemEntity.path.
   // FileSystemEntity.path will trigger UTF-8 decoding and return a path with
-  // non-UTF-8 characters replaced with �.
+  // non-UTF-8 characters replaced with U+FFFD.
 
   size_t dir_name_length = strlen(dir_name);
   uint8_t* buffer = NULL;
@@ -525,7 +525,7 @@
   // constructor. This avoids/delays interpreting the UTF-8 bytes in dir_name.
   // Later, client code may either choose to access FileSystemEntity.path.
   // FileSystemEntity.path will trigger UTF-8 decoding and return a path with
-  // non-UTF-8 characters replaced with �.
+  // non-UTF-8 characters replaced with U+FFFD.
 
   size_t link_name_length = strlen(link_name);
   uint8_t* buffer = NULL;
@@ -550,7 +550,7 @@
   // constructor. This avoids/delays interpreting the UTF-8 bytes in dir_name.
   // Later, client code may either choose to access FileSystemEntity.path.
   // FileSystemEntity.path will trigger UTF-8 decoding and return a path with
-  // non-UTF-8 characters replaced with �.
+  // non-UTF-8 characters replaced with U+FFFD.
 
   size_t file_name_length = strlen(file_name);
   uint8_t* buffer = NULL;
diff --git a/runtime/bin/utils.h b/runtime/bin/utils.h
index 8d4ab44..a5ec66b 100644
--- a/runtime/bin/utils.h
+++ b/runtime/bin/utils.h
@@ -27,6 +27,7 @@
   }
   virtual ~OSError() { free(message_); }
 
+  // Reload this OSError with the current OS error, discarding the previous.
   void Reload();
 
   SubSystem sub_system() { return sub_system_; }
diff --git a/runtime/bin/utils_android.cc b/runtime/bin/utils_android.cc
index d448efe..ed6b5de 100644
--- a/runtime/bin/utils_android.cc
+++ b/runtime/bin/utils_android.cc
@@ -22,12 +22,7 @@
 }
 
 void OSError::Reload() {
-  set_sub_system(kSystem);
-  set_code(errno);
-  const int kBufferSize = 1024;
-  char error_message[kBufferSize];
-  Utils::StrError(errno, error_message, kBufferSize);
-  SetMessage(error_message);
+  SetCodeAndMessage(kSystem, errno);
 }
 
 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) {
diff --git a/runtime/bin/utils_fuchsia.cc b/runtime/bin/utils_fuchsia.cc
index ad6e418..4c8b208 100644
--- a/runtime/bin/utils_fuchsia.cc
+++ b/runtime/bin/utils_fuchsia.cc
@@ -21,11 +21,7 @@
 }
 
 void OSError::Reload() {
-  set_sub_system(kSystem);
-  set_code(errno);
-  const int kBufferSize = 1024;
-  char error_buf[kBufferSize];
-  SetMessage(Utils::StrError(errno, error_buf, kBufferSize));
+  SetCodeAndMessage(kSystem, errno);
 }
 
 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) {
diff --git a/runtime/bin/utils_linux.cc b/runtime/bin/utils_linux.cc
index 6c7e9b7..b87778a 100644
--- a/runtime/bin/utils_linux.cc
+++ b/runtime/bin/utils_linux.cc
@@ -22,11 +22,7 @@
 }
 
 void OSError::Reload() {
-  set_sub_system(kSystem);
-  set_code(errno);
-  const int kBufferSize = 1024;
-  char error_buf[kBufferSize];
-  SetMessage(Utils::StrError(errno, error_buf, kBufferSize));
+  SetCodeAndMessage(kSystem, errno);
 }
 
 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) {
diff --git a/runtime/bin/utils_macos.cc b/runtime/bin/utils_macos.cc
index 8d3ed43..52066bc 100644
--- a/runtime/bin/utils_macos.cc
+++ b/runtime/bin/utils_macos.cc
@@ -25,12 +25,7 @@
 }
 
 void OSError::Reload() {
-  set_sub_system(kSystem);
-  set_code(errno);
-  const int kBufferSize = 1024;
-  char error_message[kBufferSize];
-  Utils::StrError(errno, error_message, kBufferSize);
-  SetMessage(error_message);
+  SetCodeAndMessage(kSystem, errno);
 }
 
 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) {
diff --git a/runtime/bin/utils_win.cc b/runtime/bin/utils_win.cc
index bc5f934..f4764b4 100644
--- a/runtime/bin/utils_win.cc
+++ b/runtime/bin/utils_win.cc
@@ -36,13 +36,7 @@
 }
 
 void OSError::Reload() {
-  set_code(GetLastError());
-
-  static const int kMaxMessageLength = 256;
-  wchar_t message[kMaxMessageLength];
-  FormatMessageIntoBuffer(code_, message, kMaxMessageLength);
-  char* utf8 = StringUtilsWin::WideToUtf8(message);
-  SetMessage(utf8);
+  SetCodeAndMessage(kSystem, GetLastError());
 }
 
 void OSError::SetCodeAndMessage(SubSystem sub_system, int code) {