From f5903a91e006da1568d8d60074bc8908b7da75d0 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 25 Feb 2021 18:11:01 -0800 Subject: [PATCH] Remove dead ensureDirectoryExists (#76829) --- .../flutter_tools/lib/src/base/file_system.dart | 14 -------------- .../test/general.shard/base/file_system_test.dart | 10 ---------- 2 files changed, 24 deletions(-) diff --git a/packages/flutter_tools/lib/src/base/file_system.dart b/packages/flutter_tools/lib/src/base/file_system.dart index e71cf6b2c9..f74e310e21 100644 --- a/packages/flutter_tools/lib/src/base/file_system.dart +++ b/packages/flutter_tools/lib/src/base/file_system.dart @@ -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) { diff --git a/packages/flutter_tools/test/general.shard/base/file_system_test.dart b/packages/flutter_tools/test/general.shard/base/file_system_test.dart index 73cfd60456..b4215b5f93 100644 --- a/packages/flutter_tools/test/general.shard/base/file_system_test.dart +++ b/packages/flutter_tools/test/general.shard/base/file_system_test.dart @@ -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();