@@ -166,31 +166,20 @@ impl RealFileSystem {
166166 // Return error for unsupported file types instead of treating as file
167167 return Err ( Error :: IoWithPath {
168168 err : io:: Error :: new ( io:: ErrorKind :: Other , "Unsupported file type" ) ,
169- path : Arc :: new ( AbsolutePath :: new ( path) . ok_or_else ( || {
170- Error :: IoWithPath {
171- err : io:: Error :: new (
172- io:: ErrorKind :: InvalidInput ,
173- "Invalid path" ,
174- ) ,
175- path : Arc :: new ( AbsolutePath :: new ( "/" ) . unwrap ( ) ) ,
176- }
177- } ) ?) ,
169+ path : Arc :: new ( AbsolutePath :: new ( path) . unwrap_or_else ( || {
170+ AbsolutePath :: new ( if cfg ! ( windows) { "C:\\ " } else { "/" } )
171+ . unwrap ( )
172+ } ) ) ,
178173 } ) ;
179174 }
180175 }
181176 Err ( err) => {
182177 // Return error instead of treating as file
183178 return Err ( Error :: IoWithPath {
184179 err,
185- path : Arc :: new ( AbsolutePath :: new ( path) . ok_or_else ( || {
186- Error :: IoWithPath {
187- err : io:: Error :: new (
188- io:: ErrorKind :: InvalidInput ,
189- "Invalid path" ,
190- ) ,
191- path : Arc :: new ( AbsolutePath :: new ( "/" ) . unwrap ( ) ) ,
192- }
193- } ) ?) ,
180+ path : Arc :: new ( AbsolutePath :: new ( path) . unwrap_or_else ( || {
181+ AbsolutePath :: new ( if cfg ! ( windows) { "C:\\ " } else { "/" } ) . unwrap ( )
182+ } ) ) ,
194183 } ) ;
195184 }
196185 } ;
@@ -207,15 +196,9 @@ impl RealFileSystem {
207196 io:: ErrorKind :: InvalidData ,
208197 "Invalid UTF-8 in filename" ,
209198 ) ,
210- path : Arc :: new ( AbsolutePath :: new ( path) . ok_or_else ( || {
211- Error :: IoWithPath {
212- err : io:: Error :: new (
213- io:: ErrorKind :: InvalidInput ,
214- "Invalid path" ,
215- ) ,
216- path : Arc :: new ( AbsolutePath :: new ( "/" ) . unwrap ( ) ) ,
217- }
218- } ) ?) ,
199+ path : Arc :: new ( AbsolutePath :: new ( path) . unwrap_or_else ( || {
200+ AbsolutePath :: new ( if cfg ! ( windows) { "C:\\ " } else { "/" } ) . unwrap ( )
201+ } ) ) ,
219202 } ) ;
220203 }
221204 }
0 commit comments