lib/file: reimplement os.OpenFile allowing rename/delete open files under Windows

Normally os.OpenFile under Windows does not allow renaming or deleting
open file handles.  This package provides equivelents for os.OpenFile,
os.Open and os.Create which do allow that.
This commit is contained in:
Nick Craig-Wood
2019-01-07 14:47:19 +00:00
parent 571b4c060b
commit 42d997f639
4 changed files with 257 additions and 0 deletions

15
lib/file/file_other.go Normal file
View File

@ -0,0 +1,15 @@
//+build !windows
package file
import "os"
// OpenFile is the generalized open call; most users will use Open or Create
// instead. It opens the named file with specified flag (O_RDONLY etc.) and
// perm (before umask), if applicable. If successful, methods on the returned
// File can be used for I/O. If there is an error, it will be of type
// *PathError.
//
// Under both Unix and Windows this will allow open files to be
// renamed and or deleted.
var OpenFile = os.OpenFile