Remove dead ensureDirectoryExists (#76829)
This commit is contained in:
parent
cc813bf153
commit
f5903a91e0
@ -8,7 +8,6 @@ import 'package:file/file.dart';
|
||||
import 'package:file/local.dart' as local_fs;
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'common.dart' show throwToolExit;
|
||||
import 'io.dart';
|
||||
import 'platform.dart';
|
||||
import 'process.dart';
|
||||
@ -41,19 +40,6 @@ class FileSystemUtils {
|
||||
|
||||
final Platform _platform;
|
||||
|
||||
/// Create the ancestor directories of a file path if they do not already exist.
|
||||
void ensureDirectoryExists(String filePath) {
|
||||
final String dirPath = _fileSystem.path.dirname(filePath);
|
||||
if (_fileSystem.isDirectorySync(dirPath)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
_fileSystem.directory(dirPath).createSync(recursive: true);
|
||||
} on FileSystemException catch (e) {
|
||||
throwToolExit('Failed to create directory "$dirPath": ${e.osError.message}');
|
||||
}
|
||||
}
|
||||
|
||||
/// Appends a number to a filename in order to make it unique under a
|
||||
/// directory.
|
||||
File getUniqueFile(Directory dir, String baseName, String ext) {
|
||||
|
@ -30,16 +30,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('ensureDirectoryExists recursively creates a directory if it does not exist', () async {
|
||||
fsUtils.ensureDirectoryExists('foo/bar/baz.flx');
|
||||
expect(fs.isDirectorySync('foo/bar'), true);
|
||||
});
|
||||
|
||||
testWithoutContext('ensureDirectoryExists throws tool exit on failure to create', () async {
|
||||
fs.file('foo').createSync();
|
||||
expect(() => fsUtils.ensureDirectoryExists('foo/bar.flx'), throwsToolExit());
|
||||
});
|
||||
|
||||
testWithoutContext('getUniqueFile creates a unique file name', () async {
|
||||
final File fileA = fsUtils.getUniqueFile(fs.currentDirectory, 'foo', 'json')
|
||||
..createSync();
|
||||
|
Loading…
x
Reference in New Issue
Block a user