currentDirectory property

Directory currentDirectory
override

Creates a directory object pointing to the current working directory.

NOTE This does not proxy to the underlying file system's current directory in any way; the state of this file system's current directory is local to this file system.

Implementation

@override
Directory get currentDirectory => directory(_cwd);
void currentDirectory= (dynamic path)
override

Sets the current working directory to the specified path.

NOTE This does not proxy to the underlying file system's current directory in any way; the state of this file system's current directory is local to this file system. Gets the path context for this file system given the current working dir.

Implementation

@override
set currentDirectory(dynamic path) {
  String value;
  if (path is io.Directory) {
    value = path.path;
  } else if (path is String) {
    value = path;
  } else {
    throw new ArgumentError('Invalid type for "path": ${path?.runtimeType}');
  }

  value = _resolve(value, notFound: _NotFoundBehavior.throwError);
  String realPath = _real(value, resolve: false);
  switch (delegate.typeSync(realPath, followLinks: false)) {
    case FileSystemEntityType.directory:
      break;
    case FileSystemEntityType.notFound:
      throw common.noSuchFileOrDirectory(path);
    default:
      throw common.notADirectory(path);
  }
  assert(() {
    p.Context ctx = delegate.path;
    return ctx.isAbsolute(value) && value == ctx.canonicalize(value);
  }());
  _cwd = value;
}