Unverified Commit f5903a91 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Remove dead ensureDirectoryExists (#76829)

parent cc813bf1
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment