github.com/10XDev/rclone@v1.52.3-0.20200626220027-16af9ab76b2a/lib/file/file.go (about) 1 // Package file provides a version of os.OpenFile, the handles of 2 // which can be renamed and deleted under Windows. 3 package file 4 5 import "os" 6 7 // Open opens the named file for reading. If successful, methods on 8 // the returned file can be used for reading; the associated file 9 // descriptor has mode O_RDONLY. 10 // If there is an error, it will be of type *PathError. 11 func Open(name string) (*os.File, error) { 12 return OpenFile(name, os.O_RDONLY, 0) 13 } 14 15 // Create creates the named file with mode 0666 (before umask), truncating 16 // it if it already exists. If successful, methods on the returned 17 // File can be used for I/O; the associated file descriptor has mode 18 // O_RDWR. 19 // If there is an error, it will be of type *PathError. 20 func Create(name string) (*os.File, error) { 21 return OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) 22 }