blob: ca4617b0103c1bb95942c09cfe49a7256f05890a [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/file.dart';
import 'package:file/src/io.dart' as io;
import 'local_directory.dart';
import 'local_file.dart';
import 'local_link.dart';
/// [FileSystemEntity] implementation that forwards all calls to `dart:io`.
abstract class LocalFileSystemEntity<T extends FileSystemEntity,
D extends io.FileSystemEntity> extends ForwardingFileSystemEntity<T, D> {
/// Instantiates a new [LocalFileSystemEntity] tied to the specified file
/// system and delegating to the specified [delegate].
LocalFileSystemEntity(this.fileSystem, this.delegate);
final FileSystem fileSystem;
final D delegate;
String get dirname => fileSystem.path.dirname(path);
String get basename => fileSystem.path.basename(path);
Directory wrapDirectory(io.Directory delegate) =>
LocalDirectory(fileSystem, delegate);
File wrapFile(io.File delegate) => LocalFile(fileSystem, delegate);
Link wrapLink(io.Link delegate) => LocalLink(fileSystem, delegate);