// Create creates a temporary file in the same directory as filename,
// which will be renamed to the given filename when calling Commit.

Create creates a temporary file in the same directory as filename,
which will be renamed to the given filename when calling Commit.
// Create creates a temporary file in the same directory as filename // which will be renamed to the given filename when calling Commit .
func Create(filename string, perm os.FileMode) (*File, error) {
	for {
		tempname, err := makeTempName(filename, "sf")
		if err != nil {
			return nil, err
		}
		f, err := os.OpenFile(tempname, os.O_RDWR|os.O_CREATE|os.O_EXCL, perm)
		if err != nil {
			if os.IsExist(err) {
				continue
			}
			return nil, err
		}
		return &File{
			File:      f,
			origName:  filename,
			closeFunc: closeUncommitted,
		}, nil
	}
}
func Create ( filename string , perm os . FileMode ) ( * File , error ) { for { tempname , err := makeTempName ( filename , " " ) if err != nil { return nil , err } f , err := os . OpenFile ( tempname , os . O_RDWR | os . O_CREATE | os . O_EXCL , perm ) if err != nil { if os . IsExist ( err ) { continue } return nil , err } return & File { File : f , origName : filename , closeFunc : closeUncommitted , } , nil } }
Create creates a temporary file in the same directory as filename,
which will be renamed to the given filename when calling Commit.
Create creates a temporary file in the same directory as filename which will be renamed to the given filename when calling Commit .