File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
packages/lw_file_system/lib/src/api Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,17 @@ abstract class GeneralFileSystem {
104104 return variant;
105105 }
106106
107+ Future <String ?> toRelativePath (String path) async {
108+ final root = await getDirectory ();
109+ if (universalPathContext.isRelative (path)) {
110+ return normalizePath (path);
111+ }
112+ if (universalPathContext.isWithin (root, path)) {
113+ return universalPathContext.relative (path, from: root);
114+ }
115+ return null ;
116+ }
117+
107118 Future <Uint8List ?> loadAbsolute (String path) => Future .value (null );
108119
109120 Future <void > saveAbsolute (String path, Uint8List bytes) => Future .value ();
Original file line number Diff line number Diff line change @@ -188,6 +188,9 @@ class WebDirectoryFileSystem extends DirectoryFileSystem with WebFileSystem {
188188 return doc != null ;
189189 }
190190
191+ @override
192+ Future <String ?> toRelativePath (String path) => Future .value (null );
193+
191194 @override
192195 Future <bool > updateFile (
193196 String path,
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ import 'dart:io';
33
44import 'package:flutter/foundation.dart' ;
55import 'package:lw_file_system/lw_file_system.dart' ;
6- import 'package:path/path.dart' as p;
76import 'package:synchronized/synchronized.dart' ;
87
98Future <void > _updateFile ((String , Uint8List ) e) async {
@@ -134,7 +133,7 @@ class IODirectoryFileSystem extends DirectoryFileSystem {
134133 (await directory.list (followLinks: false ).toList ()).map ((e) async {
135134 final current = universalPathContext.join (
136135 path,
137- p .relative (e.path, from: absolutePath),
136+ universalPathContext .relative (e.path, from: absolutePath),
138137 );
139138 if (e is File ) {
140139 return RawFileSystemFile (
You can’t perform that action at this time.
0 commit comments