Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b2938f40
Commit
b2938f40
authored
Jun 10, 2016
by
Devon Carew
Committed by
GitHub
Jun 10, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expose the devfs api (#4521)
parent
d97ec683
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
+88
-0
observatory.dart
packages/flutter_tools/lib/src/observatory.dart
+88
-0
No files found.
packages/flutter_tools/lib/src/observatory.dart
View file @
b2938f40
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'dart:async'
;
import
'dart:convert'
show
BASE64
;
import
'dart:io'
;
import
'package:json_rpc_2/json_rpc_2.dart'
as
rpc
;
...
...
@@ -130,6 +131,74 @@ class Observatory {
Future
<
Response
>
getVMTimeline
()
=>
sendRequest
(
'_getVMTimeline'
);
// DevFS / VM virtual file system methods
/// Create a new file system.
///
/// When you create a file system you provide a fsName parameter. Given the
/// [fsName] parameter you can build all the URIs you need with the following
/// format:
///
/// dart-devfs://$fsName/$path
Future
<
Response
>
createDevFS
(
String
fsName
)
{
return
sendRequest
(
'_createDevFS'
,
<
String
,
dynamic
>
{
'fsName'
:
fsName
});
}
/// List the available file systems.
Future
<
List
<
String
>>
listDevFS
()
{
return
sendRequest
(
'_listDevFS'
).
then
((
Response
response
)
{
return
response
.
response
[
'fsNames'
];
});
}
// Write one file into a file system.
Future
<
Response
>
writeDevFSFile
(
String
fsName
,
{
String
path
,
List
<
int
>
fileContents
})
{
assert
(
path
!=
null
);
assert
(
fileContents
!=
null
);
return
sendRequest
(
'_writeDevFSFile'
,
<
String
,
dynamic
>
{
'fsName'
:
fsName
,
'path'
:
path
,
'fileContents'
:
BASE64
.
encode
(
fileContents
)
});
}
// Write multiple files into a file system.
Future
<
Response
>
writeDevFSFiles
(
String
fsName
,
{
String
path
,
List
<
DevFSFile
>
files
})
{
assert
(
path
!=
null
);
assert
(
files
!=
null
);
return
sendRequest
(
'_writeDevFSFiles'
,
<
String
,
dynamic
>
{
'fsName'
:
fsName
,
'files'
:
files
.
map
((
DevFSFile
file
)
=>
file
.
toJson
()).
toList
()
});
}
// Read one file from a file system.
Future
<
List
<
int
>>
readDevFSFile
()
{
return
sendRequest
(
'_readDevFSFile'
).
then
((
Response
response
)
{
return
BASE64
.
decode
(
response
.
response
[
'fileContents'
]);
});
}
/// The complete list of a file system.
Future
<
List
<
String
>>
listDevFSFiles
()
{
return
sendRequest
(
'_listDevFSFiles'
).
then
((
Response
response
)
{
return
response
.
response
[
'files'
];
});
}
/// Delete an existing file system.
Future
<
Response
>
deleteDevFS
(
String
fsName
)
{
return
sendRequest
(
'_deleteDevFS'
,
<
String
,
dynamic
>
{
'fsName'
:
fsName
});
}
// Flutter extension methods.
Future
<
Response
>
flutterExit
(
String
isolateId
)
{
...
...
@@ -150,6 +219,25 @@ class Observatory {
}
}
abstract
class
DevFSFile
{
DevFSFile
(
this
.
path
);
final
String
path
;
List
<
int
>
getContents
();
List
<
String
>
toJson
()
=>
<
String
>[
path
,
BASE64
.
encode
(
getContents
())];
}
class
ByteDevFSFile
extends
DevFSFile
{
ByteDevFSFile
(
String
path
,
this
.
contents
):
super
(
path
);
final
List
<
int
>
contents
;
@override
List
<
int
>
getContents
()
=>
contents
;
}
class
Response
{
Response
(
this
.
response
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment