@@ -94,39 +94,38 @@ pub(crate) trait PathFileSystem: Send + Sync {
94
94
async fn init ( & self ) -> Result < ( ) > ;
95
95
96
96
/// Get the file stat by file path, if the file is exist, return the file stat
97
- async fn stat ( & self , name : & str ) -> Result < FileStat > ;
97
+ async fn stat ( & self , path : & str ) -> Result < FileStat > ;
98
98
99
- /// Get the file stat by parent file path and file name , if the file is exist, return the file stat
100
- async fn lookup ( & self , parent : & str , name : & str ) -> Result < FileStat > ;
99
+ /// Get the file stat by file path, if the file is exist, return the file stat
100
+ async fn lookup ( & self , path : & str ) -> Result < FileStat > ;
101
101
102
102
/// Read the directory by file path, if the file is a valid directory, return the file stat list
103
- async fn read_dir ( & self , name : & str ) -> Result < Vec < FileStat > > ;
103
+ async fn read_dir ( & self , path : & str ) -> Result < Vec < FileStat > > ;
104
104
105
105
/// Open the file by file path and flags, if the file is exist, return the opened file
106
- async fn open_file ( & self , name : & str , flags : OpenFileFlags ) -> Result < OpenedFile > ;
106
+ async fn open_file ( & self , path : & str , flags : OpenFileFlags ) -> Result < OpenedFile > ;
107
107
108
108
/// Open the directory by file path and flags, if the file is exist, return the opened file
109
- async fn open_dir ( & self , name : & str , flags : OpenFileFlags ) -> Result < OpenedFile > ;
109
+ async fn open_dir ( & self , path : & str , flags : OpenFileFlags ) -> Result < OpenedFile > ;
110
110
111
- /// Create the file by parent file path and file name and flags, if successful, return the opened file
111
+ /// Create the file by file path and flags, if successful, return the opened file
112
112
async fn create_file (
113
113
& self ,
114
- parent : & str ,
115
- name : & str ,
114
+ path : & str ,
116
115
flags : OpenFileFlags ,
117
116
) -> Result < OpenedFile > ;
118
117
119
- /// Create the directory by parent file path and file name , if successful, return the file stat
120
- async fn create_dir ( & self , parent : & str , name : & str ) -> Result < FileStat > ;
118
+ /// Create the directory by file path , if successful, return the file stat
119
+ async fn create_dir ( & self , path : & str ) -> Result < FileStat > ;
121
120
122
121
/// Set the file attribute by file path and file stat
123
- async fn set_attr ( & self , name : & str , file_stat : & FileStat , flush : bool ) -> Result < ( ) > ;
122
+ async fn set_attr ( & self , path : & str , file_stat : & FileStat , flush : bool ) -> Result < ( ) > ;
124
123
125
- /// Remove the file by parent file path and file name
126
- async fn remove_file ( & self , parent : & str , name : & str ) -> Result < ( ) > ;
124
+ /// Remove the file by file path
125
+ async fn remove_file ( & self , path : & str ) -> Result < ( ) > ;
127
126
128
- /// Remove the directory by parent file path and file name
129
- async fn remove_dir ( & self , parent : & str , name : & str ) -> Result < ( ) > ;
127
+ /// Remove the directory by file path
128
+ async fn remove_dir ( & self , path : & str ) -> Result < ( ) > ;
130
129
}
131
130
132
131
// FileSystemContext is the system environment for the fuse file system.
@@ -505,7 +504,8 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
505
504
506
505
async fn lookup ( & self , parent_file_id : u64 , name : & str ) -> Result < FileStat > {
507
506
let parent_file_entry = self . get_file_entry ( parent_file_id) . await ?;
508
- let mut file_stat = self . fs . lookup ( & parent_file_entry. path , name) . await ?;
507
+ let path = join_file_path ( & parent_file_entry. path , name) ;
508
+ let mut file_stat = self . fs . lookup ( & path) . await ?;
509
509
// fill the file id to file stat
510
510
self . resolve_file_id_to_filestat ( & mut file_stat, parent_file_id)
511
511
. await ;
@@ -533,9 +533,10 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
533
533
534
534
async fn create_file ( & self , parent_file_id : u64 , name : & str , flags : u32 ) -> Result < FileHandle > {
535
535
let parent_file_entry = self . get_file_entry ( parent_file_id) . await ?;
536
+ let path = join_file_path ( & parent_file_entry. path , name) ;
536
537
let mut opened_file = self
537
538
. fs
538
- . create_file ( & parent_file_entry . path , name , OpenFileFlags ( flags) )
539
+ . create_file ( & path, OpenFileFlags ( flags) )
539
540
. await ?;
540
541
541
542
opened_file. set_file_id ( parent_file_id, self . next_file_id ( ) ) ;
@@ -558,7 +559,8 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
558
559
559
560
async fn create_dir ( & self , parent_file_id : u64 , name : & str ) -> Result < u64 > {
560
561
let parent_file_entry = self . get_file_entry ( parent_file_id) . await ?;
561
- let mut filestat = self . fs . create_dir ( & parent_file_entry. path , name) . await ?;
562
+ let path = join_file_path ( & parent_file_entry. path , name) ;
563
+ let mut filestat = self . fs . create_dir ( & path) . await ?;
562
564
563
565
filestat. set_file_id ( parent_file_id, self . next_file_id ( ) ) ;
564
566
@@ -577,7 +579,8 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
577
579
578
580
async fn remove_file ( & self , parent_file_id : u64 , name : & str ) -> Result < ( ) > {
579
581
let parent_file_entry = self . get_file_entry ( parent_file_id) . await ?;
580
- self . fs . remove_file ( & parent_file_entry. path , name) . await ?;
582
+ let path = join_file_path ( & parent_file_entry. path , name) ;
583
+ self . fs . remove_file ( & path) . await ?;
581
584
582
585
// remove the file from file entry manager
583
586
{
@@ -589,7 +592,8 @@ impl<T: PathFileSystem> RawFileSystem for DefaultRawFileSystem<T> {
589
592
590
593
async fn remove_dir ( & self , parent_file_id : u64 , name : & str ) -> Result < ( ) > {
591
594
let parent_file_entry = self . get_file_entry ( parent_file_id) . await ?;
592
- self . fs . remove_dir ( & parent_file_entry. path , name) . await ?;
595
+ let path = join_file_path ( & parent_file_entry. path , name) ;
596
+ self . fs . remove_dir ( & path) . await ?;
593
597
594
598
// remove the dir from file entry manager
595
599
{
0 commit comments