Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: analyzer/lib/src/generated/java_io.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « analyzer/lib/src/generated/java_engine_io.dart ('k') | analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 library java.io;
2
3 import "dart:io";
4
5 import 'package:path/path.dart' as pathos;
6
7 import 'java_core.dart' show JavaIOException;
8
9 class JavaFile {
10 static final String separator = Platform.pathSeparator;
11 static final int separatorChar = Platform.pathSeparator.codeUnitAt(0);
12 String _path;
13 JavaFile(String path) {
14 _path = path;
15 }
16 JavaFile.fromUri(Uri uri) : this(pathos.fromUri(uri));
17 JavaFile.relative(JavaFile base, String child) {
18 if (child.isEmpty) {
19 this._path = base._path;
20 } else {
21 this._path = pathos.join(base._path, child);
22 }
23 }
24 int get hashCode => _path.hashCode;
25 bool operator ==(other) {
26 return other is JavaFile && other._path == _path;
27 }
28 bool exists() {
29 if (_newFile().existsSync()) {
30 return true;
31 }
32 if (_newDirectory().existsSync()) {
33 return true;
34 }
35 return false;
36 }
37 JavaFile getAbsoluteFile() => new JavaFile(getAbsolutePath());
38 String getAbsolutePath() {
39 String path = pathos.absolute(_path);
40 path = pathos.normalize(path);
41 return path;
42 }
43 JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath());
44 String getCanonicalPath() {
45 try {
46 return _newFile().resolveSymbolicLinksSync();
47 } catch (e) {
48 throw new JavaIOException('IOException', e);
49 }
50 }
51 String getName() => pathos.basename(_path);
52 String getParent() {
53 var result = pathos.dirname(_path);
54 // "." or "/" or "C:\"
55 if (result.length < 4) return null;
56 return result;
57 }
58 JavaFile getParentFile() {
59 var parent = getParent();
60 if (parent == null) return null;
61 return new JavaFile(parent);
62 }
63 String getPath() => _path;
64 bool isDirectory() {
65 return _newDirectory().existsSync();
66 }
67 bool isExecutable() {
68 return _newFile().statSync().mode & 0x111 != 0;
69 }
70 bool isFile() {
71 return _newFile().existsSync();
72 }
73 int lastModified() {
74 try {
75 return _newFile().lastModifiedSync().millisecondsSinceEpoch;
76 } catch (exception) {
77 return -1;
78 }
79 }
80 List<JavaFile> listFiles() {
81 var files = <JavaFile>[];
82 var entities = _newDirectory().listSync();
83 for (FileSystemEntity entity in entities) {
84 files.add(new JavaFile(entity.path));
85 }
86 return files;
87 }
88 String readAsStringSync() => _newFile().readAsStringSync();
89 String toString() => _path.toString();
90 Uri toURI() {
91 String path = getAbsolutePath();
92 return pathos.toUri(path);
93 }
94 Directory _newDirectory() => new Directory(_path);
95 File _newFile() => new File(_path);
96 }
97
98 class JavaSystemIO {
99 static Map<String, String> _properties = new Map();
100 static String getenv(String name) => Platform.environment[name];
101 static String getProperty(String name) {
102 {
103 String value = _properties[name];
104 if (value != null) {
105 return value;
106 }
107 }
108 if (name == 'os.name') {
109 return Platform.operatingSystem;
110 }
111 if (name == 'line.separator') {
112 if (Platform.isWindows) {
113 return '\r\n';
114 }
115 return '\n';
116 }
117 if (name == 'com.google.dart.sdk') {
118 String exec = Platform.executable;
119 if (exec.length != 0) {
120 String sdkPath;
121 // may be "xcodebuild/ReleaseIA32/dart" with "sdk" sibling
122 {
123 var outDir = pathos.dirname(pathos.dirname(exec));
124 sdkPath = pathos.join(pathos.dirname(outDir), "sdk");
125 if (new Directory(sdkPath).existsSync()) {
126 _properties[name] = sdkPath;
127 return sdkPath;
128 }
129 }
130 // probably be "dart-sdk/bin/dart"
131 sdkPath = pathos.dirname(pathos.dirname(exec));
132 _properties[name] = sdkPath;
133 return sdkPath;
134 }
135 }
136 return null;
137 }
138 static String setProperty(String name, String value) {
139 String oldValue = _properties[name];
140 _properties[name] = value;
141 return oldValue;
142 }
143 }
OLDNEW
« no previous file with comments | « analyzer/lib/src/generated/java_engine_io.dart ('k') | analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698