22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- part of file.src.backends. chroot;
5+ part of '../ chroot.dart' ;
66
77class _ChrootDirectory extends _ChrootFileSystemEntity <Directory , io.Directory >
88 with ForwardingDirectory <Directory >, common.DirectoryAddOnsMixin {
9- _ChrootDirectory (ChrootFileSystem fs, String path) : super ( fs, path);
9+ _ChrootDirectory (super . fs, super . path);
1010
1111 factory _ChrootDirectory .wrapped (
1212 ChrootFileSystem fs,
1313 Directory delegate, {
1414 bool relative = false ,
1515 }) {
16- String localPath = fs._local (delegate.path, relative: relative);
16+ var localPath = fs._local (delegate.path, relative: relative);
1717 return _ChrootDirectory (fs, localPath);
1818 }
1919
@@ -32,7 +32,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
3232 if (await fileSystem.type (path) != expectedType) {
3333 throw common.notADirectory (path);
3434 }
35- FileSystemEntityType type = await fileSystem.type (newPath);
35+ var type = await fileSystem.type (newPath);
3636 if (type != FileSystemEntityType .notFound) {
3737 if (type != expectedType) {
3838 throw common.notADirectory (newPath);
@@ -44,7 +44,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
4444 throw common.directoryNotEmpty (newPath);
4545 }
4646 }
47- String target = await fileSystem.link (path).target ();
47+ var target = await fileSystem.link (path).target ();
4848 await fileSystem.link (path).delete ();
4949 await fileSystem.link (newPath).create (target);
5050 return fileSystem.directory (newPath);
@@ -60,7 +60,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
6060 if (fileSystem.typeSync (path) != expectedType) {
6161 throw common.notADirectory (path);
6262 }
63- FileSystemEntityType type = fileSystem.typeSync (newPath);
63+ var type = fileSystem.typeSync (newPath);
6464 if (type != FileSystemEntityType .notFound) {
6565 if (type != expectedType) {
6666 throw common.notADirectory (newPath);
@@ -72,7 +72,7 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
7272 throw common.directoryNotEmpty (newPath);
7373 }
7474 }
75- String target = fileSystem.link (path).targetSync ();
75+ var target = fileSystem.link (path).targetSync ();
7676 fileSystem.link (path).deleteSync ();
7777 fileSystem.link (newPath).createSync (target);
7878 return fileSystem.directory (newPath);
@@ -97,17 +97,15 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
9797 @override
9898 Future <Directory > create ({bool recursive = false }) async {
9999 if (_isLink) {
100- switch (await fileSystem.type (path)) {
101- case FileSystemEntityType .notFound:
102- throw common.noSuchFileOrDirectory (path);
103- case FileSystemEntityType .file:
104- throw common.fileExists (path);
105- case FileSystemEntityType .directory:
100+ return switch (await fileSystem.type (path)) {
101+ FileSystemEntityType .notFound =>
102+ throw common.noSuchFileOrDirectory (path),
103+ FileSystemEntityType .file => throw common.fileExists (path),
104+ FileSystemEntityType .directory =>
106105 // Nothing to do.
107- return this ;
108- default :
109- throw AssertionError ();
110- }
106+ this ,
107+ _ => throw AssertionError ()
108+ };
111109 } else {
112110 return wrap (await delegate.create (recursive: recursive));
113111 }
@@ -137,8 +135,8 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
137135 bool recursive = false ,
138136 bool followLinks = true ,
139137 }) {
140- Directory delegate = this .delegate as Directory ;
141- String dirname = delegate.path;
138+ var delegate = this .delegate as Directory ;
139+ var dirname = delegate.path;
142140 return delegate
143141 .list (recursive: recursive, followLinks: followLinks)
144142 .map ((io.FileSystemEntity entity) => _denormalize (entity, dirname));
@@ -149,18 +147,18 @@ class _ChrootDirectory extends _ChrootFileSystemEntity<Directory, io.Directory>
149147 bool recursive = false ,
150148 bool followLinks = true ,
151149 }) {
152- Directory delegate = this .delegate as Directory ;
153- String dirname = delegate.path;
150+ var delegate = this .delegate as Directory ;
151+ var dirname = delegate.path;
154152 return delegate
155153 .listSync (recursive: recursive, followLinks: followLinks)
156154 .map ((io.FileSystemEntity entity) => _denormalize (entity, dirname))
157155 .toList ();
158156 }
159157
160158 FileSystemEntity _denormalize (io.FileSystemEntity entity, String dirname) {
161- p. Context ctx = fileSystem.path;
162- String relativePart = ctx.relative (entity.path, from: dirname);
163- String entityPath = ctx.join (path, relativePart);
159+ var ctx = fileSystem.path;
160+ var relativePart = ctx.relative (entity.path, from: dirname);
161+ var entityPath = ctx.join (path, relativePart);
164162 if (entity is io.File ) {
165163 return _ChrootFile (fileSystem, entityPath);
166164 } else if (entity is io.Directory ) {
0 commit comments