@@ -56,7 +56,7 @@ func (fs *root) Filewrite(r *Request) (io.WriterAt, error) {
56
56
defer fs .filesLock .Unlock ()
57
57
file , err := fs .fetch (r .Filepath )
58
58
if err == os .ErrNotExist {
59
- dir , err := fs .fetch (dir (r .Filepath ))
59
+ dir , err := fs .fetch (filepath . Dir (r .Filepath ))
60
60
if err != nil {
61
61
return nil , err
62
62
}
@@ -102,7 +102,7 @@ func (fs *root) Filecmd(r *Request) error {
102
102
}
103
103
}
104
104
case "Rmdir" , "Remove" :
105
- file , err := fs .fetch (dir (r .Filepath ))
105
+ file , err := fs .fetch (filepath . Dir (r .Filepath ))
106
106
if err != nil {
107
107
return err
108
108
}
@@ -122,7 +122,7 @@ func (fs *root) Filecmd(r *Request) error {
122
122
delete (fs .files , r .Filepath )
123
123
124
124
case "Mkdir" :
125
- _ , err := fs .fetch (dir (r .Filepath ))
125
+ _ , err := fs .fetch (filepath . Dir (r .Filepath ))
126
126
if err != nil {
127
127
return err
128
128
}
@@ -183,7 +183,7 @@ func (fs *root) Filelist(r *Request) (ListerAt, error) {
183
183
}
184
184
orderedNames := []string {}
185
185
for fn := range fs .files {
186
- if dir (fn ) == r .Filepath {
186
+ if filepath . Dir (fn ) == r .Filepath {
187
187
orderedNames = append (orderedNames , fn )
188
188
}
189
189
}
@@ -305,14 +305,3 @@ func (f *memFile) WriteAt(p []byte, off int64) (int, error) {
305
305
func (f * memFile ) TransferError (err error ) {
306
306
f .transferError = err
307
307
}
308
-
309
- func dir (path string ) string {
310
- i := len (path ) - 1
311
- for i >= 0 && ! os .IsPathSeparator (path [i ]) {
312
- i --
313
- }
314
- if i == 0 {
315
- return path [:i + 1 ]
316
- }
317
- return path [:i ]
318
- }
0 commit comments