Remove java_io.dart and tests.

Change-Id: I4e3bc83896be2469c183fa0481d0c49fc79a8ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226280
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2022-01-04 19:11:30 +00:00 committed by Commit Bot
parent 3e63086553
commit 40e8e7ce5e
3 changed files with 0 additions and 153 deletions

View file

@ -1,110 +0,0 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import "dart:io";
import 'package:path/path.dart' as path;
@Deprecated('Use ResourceProvider and path context instead.')
class JavaFile {
@deprecated
static path.Context pathContext = path.context;
static final String separator = Platform.pathSeparator;
static final int separatorChar = Platform.pathSeparator.codeUnitAt(0);
late final String _path;
JavaFile(String path) {
_path = path;
}
JavaFile.fromUri(Uri uri) : this(path.context.fromUri(uri));
JavaFile.relative(JavaFile base, String child) {
if (child.isEmpty) {
_path = base._path;
} else {
_path = path.context.join(base._path, child);
}
}
@override
int get hashCode => _path.hashCode;
@override
bool operator ==(Object other) {
return other is JavaFile && other._path == _path;
}
bool exists() {
if (_newFile().existsSync()) {
return true;
}
if (_newDirectory().existsSync()) {
return true;
}
return false;
}
JavaFile getAbsoluteFile() => JavaFile(getAbsolutePath());
String getAbsolutePath() {
String abolutePath = path.context.absolute(_path);
abolutePath = path.context.normalize(abolutePath);
return abolutePath;
}
JavaFile getCanonicalFile() => JavaFile(getCanonicalPath());
String getCanonicalPath() {
return _newFile().resolveSymbolicLinksSync();
}
String getName() => path.context.basename(_path);
String? getParent() {
var result = path.context.dirname(_path);
// "." or "/" or "C:\"
if (result.length < 4) return null;
return result;
}
JavaFile? getParentFile() {
var parent = getParent();
if (parent == null) return null;
return JavaFile(parent);
}
String getPath() => _path;
bool isDirectory() {
return _newDirectory().existsSync();
}
bool isExecutable() {
return _newFile().statSync().mode & 0x111 != 0;
}
bool isFile() {
return _newFile().existsSync();
}
int lastModified() {
try {
return _newFile().lastModifiedSync().millisecondsSinceEpoch;
} catch (exception) {
return -1;
}
}
List<JavaFile> listFiles() {
var files = <JavaFile>[];
var entities = _newDirectory().listSync();
for (FileSystemEntity entity in entities) {
files.add(JavaFile(entity.path));
}
return files;
}
String readAsStringSync() => _newFile().readAsStringSync();
@override
String toString() => _path.toString();
Uri toURI() {
String absolutePath = getAbsolutePath();
return path.context.toUri(absolutePath);
}
Directory _newDirectory() => Directory(_path);
File _newFile() => File(_path);
}

View file

@ -1,41 +0,0 @@
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/src/generated/java_io.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
main() {
group('JavaFile', () {
group('toURI', () {
test('forAbsolute', () {
String tempPath = '/temp';
String absolutePath = path.context.join(tempPath, 'foo.dart');
// we use an absolute path
expect(path.context.isAbsolute(absolutePath), isTrue,
reason: '"$absolutePath" is not absolute');
// test that toURI() returns an absolute URI
// ignore: deprecated_member_use_from_same_package
Uri uri = JavaFile(absolutePath).toURI();
expect(uri.isAbsolute, isTrue);
expect(uri.scheme, 'file');
});
test('forRelative', () {
String tempPath = '/temp';
String absolutePath = path.context.join(tempPath, 'foo.dart');
expect(path.context.isAbsolute(absolutePath), isTrue,
reason: '"$absolutePath" is not absolute');
// prepare a relative path
// We should not check that "relPath" is actually relative -
// it may be not on Windows, if "temp" is on other disk.
String relPath = path.context.relative(absolutePath);
// test that toURI() returns an absolute URI
// ignore: deprecated_member_use_from_same_package
Uri uri = JavaFile(relPath).toURI();
expect(uri.isAbsolute, isTrue);
expect(uri.scheme, 'file');
});
});
});
}

View file

@ -21,7 +21,6 @@ import 'generic_metadata_parser_test.dart' as generic_metadata_parser;
import 'invalid_code_test.dart' as invalid_code;
import 'issues_test.dart' as issues;
import 'java_core_test.dart' as java_core_test;
import 'java_io_test.dart' as java_io_test;
import 'new_as_identifier_parser_test.dart' as new_as_identifier_parser;
import 'nnbd_parser_test.dart' as nnbd_parser;
import 'non_error_parser_test.dart' as non_error_parser;
@ -63,7 +62,6 @@ main() {
invalid_code.main();
issues.main();
java_core_test.main();
java_io_test.main();
new_as_identifier_parser.main();
nnbd_parser.main();
non_error_parser.main();