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) {
307307 return
308308}
309309
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+
310321// LinkError records an error during a link or symlink or rename system call and
311322// the paths that caused it.
312323type LinkError struct {
Original file line number Diff line number Diff line change @@ -149,3 +149,7 @@ func (f *File) Truncate(size int64) (err error) {
149149
150150 return Truncate (f .name , size )
151151}
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) {
151151 return Truncate (f .name , size )
152152}
153153
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+
154169// ReadAt reads up to len(b) bytes from the File starting at the given absolute offset.
155170// It returns the number of bytes read and any error encountered, possibly io.EOF.
156171// 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 {
142142 }
143143 return true
144144}
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