9f986d2501
Change-Id: Iffe4370431587e46a141ddc72a86ceec29c163b2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176486 Commit-Queue: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Samuel Rawlins <srawlins@google.com>
27 lines
1.2 KiB
Dart
27 lines
1.2 KiB
Dart
// Copyright (c) 2018, 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.
|
||
|
||
/// A utility class used to convert between URIs and absolute file paths.
|
||
abstract class UriConverter {
|
||
/// Return the URI that should be used to reference the file at the absolute
|
||
/// [path], or `null` if there is no valid way to reference the file in this
|
||
/// converter’s context. The file at that path is not required to exist.
|
||
///
|
||
/// If a [containingPath] is provided and both the [path] and [containingPath]
|
||
/// are within the root of this converter’s context, then the returned URI
|
||
/// will be a relative path. Otherwise, the returned URI will be an absolute
|
||
/// URI.
|
||
///
|
||
/// Throws an `ArgumentError` if the [path] is `null` or is not a valid
|
||
/// absolute file path.
|
||
Uri? pathToUri(String path, {String? containingPath});
|
||
|
||
/// Return the absolute path of the file to which the absolute [uri] resolves,
|
||
/// or `null` if the [uri] cannot be resolved in this converter’s context.
|
||
///
|
||
/// Throws an `ArgumentError` if the [uri] is `null` or is not an absolute
|
||
/// URI.
|
||
String? uriToPath(Uri uri);
|
||
}
|