[dartvfs] Support paths containing ./ and variant.
TEST=CQ
Change-Id: I9e1bc09e1eb138b1a07a9d8d4e1604eab5d931ac
diff --git a/public/dart/fuchsia_vfs/lib/src/pseudo_dir.dart b/public/dart/fuchsia_vfs/lib/src/pseudo_dir.dart
index a29de56..e2ea9c2 100644
--- a/public/dart/fuchsia_vfs/lib/src/pseudo_dir.dart
+++ b/public/dart/fuchsia_vfs/lib/src/pseudo_dir.dart
@@ -130,10 +130,20 @@
void open(
int flags, int mode, String path, fidl.InterfaceRequest<Node> request) {
var p = path.trim();
+ // remove all ./, .//, etc
+ while (p.startsWith('./')) {
+ var index = 2;
+ while (index < p.length && p[index] == '/') {
+ index++;
+ }
+ p = p.substring(index);
+ }
+
if (p.startsWith('/')) {
sendErrorEvent(flags, ZX.ERR_BAD_PATH, request);
return;
}
+
if (p == '' || p == '.') {
connect(flags, mode, request);
return;
diff --git a/public/dart/fuchsia_vfs/test/pseudo_dir_test.dart b/public/dart/fuchsia_vfs/test/pseudo_dir_test.dart
index 5a60d85..1bdb58e 100644
--- a/public/dart/fuchsia_vfs/test/pseudo_dir_test.dart
+++ b/public/dart/fuchsia_vfs/test/pseudo_dir_test.dart
@@ -722,7 +722,7 @@
PseudoDir dir = _setUpDir();
var proxy = _getProxyForDir(dir);
- var paths = ['.', ''];
+ var paths = ['.', '', './', './/', './//'];
for (var path in paths) {
DirectoryProxy newProxy = DirectoryProxy();
await proxy.open(0, 0, path,
@@ -739,7 +739,10 @@
var proxy = _getProxyForDir(dir);
// open file 1 check contents.
- await _openFileAndAssert(proxy, 'file1', 100, 'file1');
+ var paths = ['file1', './file1', './/file1', './//file1'];
+ for (var path in paths) {
+ await _openFileAndAssert(proxy, path, 100, 'file1');
+ }
});
test('open file fails for path ending with "/"', () async {