blob: 24dc7be506abac58dd4adbc61e0a0d57e804b1cf [file] [log] [blame]
// Copyright (c) 2017, 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.
import 'package:file/src/io.dart' as io;
/// Gets the string path represented by the specified generic [path].
String getPath(dynamic path) {
if (path is io.FileSystemEntity) {
return path.path;
} else if (path is String) {
return path;
} else if (path is Uri) {
return path.toFilePath();
} else {
throw new ArgumentError('Invalid type for "path": ${path?.runtimeType}');
}
}