func WriteFile(path string, data []byte) error {
	if IsPathExist(path) {
		return fmt.Errorf("cannot create file %q, since it already exists", path)
	}
	f, err := filestream.Create(path, false)
	if err != nil {
		return fmt.Errorf("cannot create file %q: %s", path, err)
	}
	if _, err := f.Write(data); err != nil {
		f.MustClose()
		return fmt.Errorf("cannot write %d bytes to file %q: %s", len(data), path, err)
	}

	// Sync and close the file.
	f.MustClose()

	// Sync the containing directory, so the file is guaranteed to appear in the directory.
	// See https://www.quora.com/When-should-you-fsync-the-containing-directory-in-addition-to-the-file-itself
	absPath, err := filepath.Abs(path)
	if err != nil {
		return fmt.Errorf("cannot obtain absolute path to %q: %s", path, err)
	}
	parentDirPath, _ := filepath.Split(absPath)
	SyncPath(parentDirPath)

	return nil
}
// WriteFile writes data to the given file path.
//
// WriteFile returns only after the file is fully written
// to the underlying storage.
WriteFile writes data to the given file path.

WriteFile returns only after the file is fully written
to the underlying storage.
// WriteFile writes data to the given file path . // // WriteFile returns only after the file is fully written // to the underlying storage .
func WriteFile(path string, data []byte) error {
	if IsPathExist(path) {
		return fmt.Errorf("cannot create file %q, since it already exists", path)
	}
	f, err := filestream.Create(path, false)
	if err != nil {
		return fmt.Errorf("cannot create file %q: %s", path, err)
	}
	if _, err := f.Write(data); err != nil {
		f.MustClose()
		return fmt.Errorf("cannot write %d bytes to file %q: %s", len(data), path, err)
	}
	f.MustClose()
	absPath, err := filepath.Abs(path)
	if err != nil {
		return fmt.Errorf("cannot obtain absolute path to %q: %s", path, err)
	}
	parentDirPath, _ := filepath.Split(absPath)
	SyncPath(parentDirPath)
	return nil
}
func WriteFile ( path string , data [ ] byte ) error { if IsPathExist ( path ) { return fmt . Errorf ( " " , path ) } f , err := filestream . Create ( path , false ) if err != nil { return fmt . Errorf ( " " , path , err ) } if _ , err := f . Write ( data ) ; err != nil { f . MustClose ( ) return fmt . Errorf ( " " , len ( data ) , path , err ) } f . MustClose ( ) absPath , err := filepath . Abs ( path ) if err != nil { return fmt . Errorf ( " " , path , err ) } parentDirPath , _ := filepath . Split ( absPath ) SyncPath ( parentDirPath ) return nil }
WriteFile writes data to the given file path.
WriteFile writes data to the given file path .
// Sync and close the file. // Sync the containing directory, so the file is guaranteed to appear in the directory. // See https://www.quora.com/When-should-you-fsync-the-containing-directory-in-addition-to-the-file-itself