File: writefile.go

package info (click to toggle)
glab 1.53.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,936 kB
  • sloc: sh: 295; makefile: 153; perl: 99; ruby: 68; javascript: 67
file content (22 lines) | stat: -rw-r--r-- 430 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//go:build !windows
// +build !windows

package config

import (
	"os"
	"path/filepath"

	"github.com/google/renameio/v2"
)

// WriteFile to the path
// If the path is smylink it will write to the symlink
func WriteFile(filename string, data []byte, perm os.FileMode) error {
	pathToSymlink, err := filepath.EvalSymlinks(filename)
	if err == nil {
		filename = pathToSymlink
	}

	return renameio.WriteFile(filename, data, perm)
}