Skip to content

Commit

Permalink
added MemFile.WithName and WithData
Browse files Browse the repository at this point in the history
  • Loading branch information
ungerik committed Nov 27, 2024
1 parent 794fb7b commit 0058d4c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions memfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ func (f MemFile) Name() string {
return f.FileName
}

// WithName returns a MemFile with the passed name
// and the same shared data as the original MemFile.
func (f MemFile) WithName(name string) MemFile {
return MemFile{FileName: name, FileData: f.FileData}
}

// WithData returns a MemFile with the passed data
// and the same name as the original MemFile.
func (f MemFile) WithData(data []byte) MemFile {
return MemFile{FileName: f.FileName, FileData: data}
}

// Ext returns the extension of file name including the point, or an empty string.
func (f MemFile) Ext() string {
return fsimpl.Ext(f.FileName, "")
Expand Down

0 comments on commit 0058d4c

Please sign in to comment.