@@ -11,6 +11,
10000
7 @@ import (
11
11
"os"
12
12
"path/filepath"
13
13
"sort"
14
+ "strings"
14
15
"sync"
15
16
"syscall"
16
17
"time"
@@ -90,11 +91,36 @@ func (fs *root) Filecmd(r *Request) error {
90
91
file .name = r .Target
91
92
fs .files [r .Target ] = file
92
93
delete (fs .files , r .Filepath )
94
+
95
+ if file .IsDir () {
96
+ fmt .Printf ("Rename Dir %v, %v, %v\n " , r .Target , file .name , r .Filepath )
97
+ for path , file := range fs .files {
98
+ if strings .HasPrefix (path , r .Filepath + "/" ) {
99
+ fmt .Printf ("renaming %v from %v to %v\n " , file .name , path , r .Target + path [len (r .Filepath ):])
100
+ file .name = r .Target + path [len (r .Filepath ):]
101
+ fs .files [r .Target + path [len (r .Filepath ):]] = file
102
+ delete (fs .files , path )
103
+ }
104
+ }
105
+ }
93
106
case "Rmdir" , "Remove" :
94
- _ , err := fs .fetch (filepath .Dir (r .Filepath ))
107
+ file , err := fs .fetch (filepath .Dir (r .Filepath ))
95
108
if err != nil {
96
109
return err
97
110
}
111
+
112
+ if file .IsDir () {
113
+ for path := range fs .files {
114
+ if strings .HasPrefix (path , r .Filepath + "/" ) {
115
+ return & os.PathError {
116
+ Op : "remove" ,
117
+ Path : r .Filepath + "/" ,
118
+ Err : fmt .Errorf ("directory is not empty" ),
119
+ }
120
+ }
121
+ }
122
+ }
123
+
98
124
delete (fs .files , r .Filepath )
99
125
case "Mkdir" :
100
126
_ , err := fs .fetch (filepath .Dir (r .Filepath ))
0 commit comments