Chromium Code Reviews| Index: sdk/lib/vmservice/devfs.dart |
| diff --git a/sdk/lib/vmservice/devfs.dart b/sdk/lib/vmservice/devfs.dart |
| index 7f940b9a572180831be475cc0f5855cc61da0403..0cdc57a6f107c8c638dfef01742a64aba7a39078 100644 |
| --- a/sdk/lib/vmservice/devfs.dart |
| +++ b/sdk/lib/vmservice/devfs.dart |
| @@ -42,6 +42,10 @@ class _FileSystem { |
| return null; |
| } |
| + return resolve(pathUri); |
| + } |
| + |
| + Uri resolve(Uri pathUri) { |
| try { |
| // Make sure that this pathUri can be converted to a file path. |
| pathUri.toFilePath(); |
| @@ -123,6 +127,7 @@ class DevFS { |
| Future<String> handlePutStream(Object fsName, |
| Object path, |
| + Uri fsUri, |
| Stream<List<int>> bytes) async { |
| // A dummy Message for error message construction. |
| Message message = new Message.forMethod('_writeDevFSFile'); |
| @@ -140,15 +145,23 @@ class DevFS { |
| if (fs == null) { |
| return _encodeFileSystemDoesNotExistError(message, fsName); |
| } |
| - if (path == null) { |
| - return encodeMissingParamError(message, 'path'); |
| - } |
| - if (path is! String) { |
| - return encodeInvalidParamError(message, 'path'); |
| - } |
| - Uri uri = fs.resolvePath(path); |
| + Uri uri = fsUri; |
| if (uri == null) { |
| - return encodeInvalidParamError(message, 'path'); |
| + if (path == null) { |
| + return encodeMissingParamError(message, 'path'); |
| + } |
| + if (path is! String) { |
| + return encodeInvalidParamError(message, 'path'); |
| + } |
| + uri = fs.resolvePath(path); |
| + if (uri == null) { |
| + return encodeInvalidParamError(message, 'path'); |
| + } |
| + } else { |
| + uri = fs.resolve(uri); |
| + if (uri == null) { |
| + return encodeInvalidParamError(message, 'uri'); |
| + } |
| } |
| await writeStreamFile(uri, bytes); |
| return encodeSuccess(message); |
| @@ -219,18 +232,34 @@ class DevFS { |
| if (fs == null) { |
| return _encodeFileSystemDoesNotExistError(message, fsName); |
| } |
| - var path = message.params['path']; |
| - if (path == null) { |
| - return encodeMissingParamError(message, 'path'); |
| - } |
| - if (path is! String) { |
| - return encodeInvalidParamError(message, 'path'); |
| - } |
| - Uri uri = fs.resolvePath(path); |
| - if (uri == null) { |
| - return encodeInvalidParamError(message, 'path'); |
| + Uri uri; |
| + if (message.params['uri'] != null) { |
| + try { |
| + var uriParam = message.params['uri']; |
| + if (uriParam is! String) { |
| + return encodeInvalidParamError(message, 'uri'); |
| + } |
| + Uri parsedUri = Uri.parse(uriParam); |
| + uri = fs.resolve(parsedUri); |
| + if (uri == null) { |
| + return encodeInvalidParamError(message, 'uri'); |
| + } |
| + } catch (e) { |
| + return encodeInvalidParamError(message, 'uri'); |
| + } |
| + } else { |
| + var path = message.params['path']; |
| + if (path == null) { |
| + return encodeMissingParamError(message, 'path'); |
| + } |
| + if (path is! String) { |
| + return encodeInvalidParamError(message, 'path'); |
| + } |
| + uri = fs.resolvePath(path); |
| + if (uri == null) { |
| + return encodeInvalidParamError(message, 'path'); |
| + } |
| } |
| - |
| try { |
| List<int> bytes = await readFile(uri); |
| var result = { |
| @@ -261,16 +290,33 @@ class DevFS { |
| if (fs == null) { |
| return _encodeFileSystemDoesNotExistError(message, fsName); |
| } |
| - var path = message.params['path']; |
| - if (path == null) { |
| - return encodeMissingParamError(message, 'path'); |
| - } |
| - if (path is! String) { |
| - return encodeInvalidParamError(message, 'path'); |
| - } |
| - Uri uri = fs.resolvePath(path); |
| - if (uri == null) { |
| - return encodeInvalidParamError(message, 'path'); |
| + Uri uri; |
| + if (message.params['uri'] != null) { |
| + try { |
| + var uriParam = message.params['uri']; |
| + if (uriParam is! String) { |
| + return encodeInvalidParamError(message, 'uri'); |
| + } |
| + Uri parsedUri = Uri.parse(uriParam); |
| + uri = fs.resolve(parsedUri); |
| + if (uri == null) { |
| + return encodeInvalidParamError(message, 'uri'); |
| + } |
| + } catch (e) { |
| + return encodeInvalidParamError(message, 'uri'); |
| + } |
| + } else { |
| + var path = message.params['path']; |
| + if (path == null) { |
| + return encodeMissingParamError(message, 'path'); |
| + } |
| + if (path is! String) { |
| + return encodeInvalidParamError(message, 'path'); |
| + } |
| + uri = fs.resolvePath(path); |
| + if (uri == null) { |
| + return encodeInvalidParamError(message, 'path'); |
| + } |
|
turnidge
2017/03/08 21:13:51
Does this code duplicate the code above? Can ther
Cutch
2017/03/08 23:41:07
A helper function is awkward here (see other DevFS
|
| } |
| var fileContents = message.params['fileContents']; |
| if (fileContents == null) { |