mirror of https://github.com/spf13/afero.git
prevent changes when O_RDONLY is set
This commit is contained in:
parent
e7cb826c1f
commit
8064ebdcd1
|
@ -207,6 +207,9 @@ func (m *MemMapFs) lockfreeOpen(name string) (File, error) {
|
|||
|
||||
func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
|
||||
file, err := m.Open(name)
|
||||
if flag&os.O_RDONLY > 0 {
|
||||
return file, err
|
||||
}
|
||||
if os.IsNotExist(err) && (flag&os.O_CREATE > 0) {
|
||||
file, err = m.Create(name)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue