File tree Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Expand file tree Collapse file tree 4 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -307,6 +307,17 @@ func (f *File) Sync() (err error) {
307
307
return
308
308
}
309
309
310
+ // Chmod changes the mode of the file to mode. If there is an error, it will be
311
+ // of type *PathError.
312
+ func (f * File ) Chmod (mode FileMode ) (err error ) {
313
+ if f .handle == nil {
314
+ err = ErrClosed
315
+ } else {
316
+ err = f .chmod (mode )
317
+ }
318
+ return
319
+ }
320
+
310
321
// LinkError records an error during a link or symlink or rename system call and
311
322
// the paths that caused it.
312
323
type LinkError struct {
Original file line number Diff line number Diff line change @@ -149,3 +149,7 @@ func (f *File) Truncate(size int64) (err error) {
149
149
150
150
return Truncate (f .name , size )
151
151
}
152
+
153
+ func (f * File ) chmod (mode FileMode ) error {
154
+ return ErrUnsupported
155
+ }
Original file line number Diff line number Diff line change @@ -151,6 +151,21 @@ func (f *File) Truncate(size int64) (err error) {
151
151
return Truncate (f .name , size )
152
152
}
153
153
154
+ func (f * File ) chmod (mode FileMode ) error {
155
+ if f .handle == nil {
156
+ return ErrClosed
157
+ }
158
+
159
+ longName := fixLongPath (f .name )
160
+ e := ignoringEINTR (func () error {
161
+ return syscall .Chmod (longName , syscallMode (mode ))
162
+ })
163
+ if e != nil {
164
+ return & PathError {Op : "chmod" , Path : f .name , Err : e }
165
+ }
166
+ return nil
167
+ }
168
+
154
169
// ReadAt reads up to len(b) bytes from the File starting at the given absolute offset.
155
170
// It returns the number of bytes read and any error encountered, possibly io.EOF.
156
171
// At end of file, Pread returns 0, io.EOF.
Original file line number Diff line number Diff line change @@ -142,3 +142,7 @@ func isWindowsNulName(name string) bool {
142
142
}
143
143
return true
144
144
}
145
+
146
+ func (f * File ) chmod (mode FileMode ) error {
147
+ return ErrNotImplemented
148
+ }
You can’t perform that action at this time.
0 commit comments