Index: pkg/watcher/lib/src/utils.dart |
diff --git a/pkg/watcher/lib/src/utils.dart b/pkg/watcher/lib/src/utils.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..319835ec944f3c955db24a0006e8f9e60cb4c54b |
--- /dev/null |
+++ b/pkg/watcher/lib/src/utils.dart |
@@ -0,0 +1,16 @@ |
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library watcher.utils; |
+ |
+import 'dart:io'; |
+ |
+/// Returns `true` if [error] is a [DirectoryException] for a missing directory. |
+bool isDirectoryNotFoundException(error) { |
+ if (error is! DirectoryException) return false; |
+ |
+ // See dartbug.com/12461 and tests/standalone/io/directory_error_test.dart. |
+ var notFoundCode = Platform.operatingSystem == "windows" ? 3 : 2; |
+ return error.osError.errorCode == notFoundCode; |
+} |