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

Side by Side Diff: pkg/analyzer/lib/file_system/physical_file_system.dart

Issue 2324513002: Issue 27243. Don't attempt to read Windows device drivers. (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.file_system.physical_file_system; 5 library analyzer.file_system.physical_file_system;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:core' hide Resource; 8 import 'dart:core' hide Resource;
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 return new FileSource(this, uri ?? pathContext.toUri(path)); 145 return new FileSource(this, uri ?? pathContext.toUri(path));
146 } 146 }
147 147
148 @override 148 @override
149 bool isOrContains(String path) { 149 bool isOrContains(String path) {
150 return path == this.path; 150 return path == this.path;
151 } 151 }
152 152
153 @override 153 @override
154 List<int> readAsBytesSync() { 154 List<int> readAsBytesSync() {
155 _throwIfWindowsDeviceDriver();
155 try { 156 try {
156 return _file.readAsBytesSync(); 157 return _file.readAsBytesSync();
157 } on io.FileSystemException catch (exception) { 158 } on io.FileSystemException catch (exception) {
158 throw new FileSystemException(exception.path, exception.message); 159 throw new FileSystemException(exception.path, exception.message);
159 } 160 }
160 } 161 }
161 162
162 @override 163 @override
163 String readAsStringSync() { 164 String readAsStringSync() {
165 _throwIfWindowsDeviceDriver();
164 try { 166 try {
165 return FileBasedSource.fileReadMode(_file.readAsStringSync()); 167 return FileBasedSource.fileReadMode(_file.readAsStringSync());
166 } on io.FileSystemException catch (exception) { 168 } on io.FileSystemException catch (exception) {
167 throw new FileSystemException(exception.path, exception.message); 169 throw new FileSystemException(exception.path, exception.message);
168 } 170 }
169 } 171 }
170 172
171 @override 173 @override
172 File renameSync(String newPath) { 174 File renameSync(String newPath) {
173 try { 175 try {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 void delete() { 346 void delete() {
345 try { 347 try {
346 _entry.deleteSync(recursive: true); 348 _entry.deleteSync(recursive: true);
347 } on io.FileSystemException catch (exception) { 349 } on io.FileSystemException catch (exception) {
348 throw new FileSystemException(exception.path, exception.message); 350 throw new FileSystemException(exception.path, exception.message);
349 } 351 }
350 } 352 }
351 353
352 @override 354 @override
353 String toString() => path; 355 String toString() => path;
356
357 /**
358 * If the operating system is Windows and the resource references one of the
359 * device drivers, throw a [FileSystemException].
360 *
361 * https://support.microsoft.com/en-us/kb/74496
362 */
363 void _throwIfWindowsDeviceDriver() {
364 if (io.Platform.isWindows) {
365 String shortName = this.shortName.toUpperCase();
366 if (shortName == r'CON' ||
367 shortName == r'PRN' ||
368 shortName == r'AUX' ||
369 shortName == r'CLOCK$' ||
370 shortName == r'NUL' ||
371 shortName == r'COM1' ||
372 shortName == r'LPT1' ||
373 shortName == r'LPT2' ||
374 shortName == r'LPT3' ||
375 shortName == r'COM2' ||
376 shortName == r'COM3' ||
377 shortName == r'COM4') {
378 throw new FileSystemException(
379 path, 'Windows device drivers cannot be read.');
380 }
381 }
382 }
354 } 383 }
355 384
356 /** 385 /**
357 * This class encapsulates logic for creating a single [IsolateRunner]. 386 * This class encapsulates logic for creating a single [IsolateRunner].
358 */ 387 */
359 class _SingleIsolateRunnerProvider { 388 class _SingleIsolateRunnerProvider {
360 bool _isSpawning = false; 389 bool _isSpawning = false;
361 IsolateRunner _runner; 390 IsolateRunner _runner;
362 391
363 /** 392 /**
(...skipping 11 matching lines...) Expand all
375 timer.cancel(); 404 timer.cancel();
376 } 405 }
377 }); 406 });
378 return completer.future; 407 return completer.future;
379 } 408 }
380 _isSpawning = true; 409 _isSpawning = true;
381 _runner = await IsolateRunner.spawn(); 410 _runner = await IsolateRunner.spawn();
382 return _runner; 411 return _runner;
383 } 412 }
384 } 413 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698