File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -140,4 +140,6 @@ type File interface {
140
140
Lock () error
141
141
// Unlock unlocks the file.
142
142
Unlock () error
143
+ // Truncate the file.
144
+ Truncate (size int64 ) error
143
145
}
Original file line number Diff line number Diff line change @@ -270,6 +270,13 @@ func (f *file) Close() error {
270
270
return nil
271
271
}
272
272
273
+ func (f * file ) Truncate (size int64 ) error {
274
+ if size < int64 (len (f .content .bytes )) {
275
+ f .content .bytes = f .content .bytes [:size ]
276
+ }
277
+ return nil
278
+ }
279
+
273
280
func (f * file ) Duplicate (filename string , mode os.FileMode , flag int ) billy.File {
274
281
new := & file {
275
282
name : filename ,
Original file line number Diff line number Diff line change @@ -130,3 +130,7 @@ func (*FileMock) Lock() error {
130
130
func (* FileMock ) Unlock () error {
131
131
return nil
132
132
}
133
+
134
+ func (* FileMock ) Truncate (size int64 ) error {
135
+ return nil
136
+ }
You can’t perform that action at this time.
0 commit comments