MCPcopy Create free account
hub / github.com/google/pprof / writeSettings

Function writeSettings

internal/driver/settings.go:53–70  ·  view source on GitHub ↗

writeSettings saves settings to fname.

(fname string, settings *settings)

Source from the content-addressed store, hash-verified

51
52// writeSettings saves settings to fname.
53func writeSettings(fname string, settings *settings) error {
54 data, err := json.MarshalIndent(settings, "", " ")
55 if err != nil {
56 return fmt.Errorf("could not encode settings: %w", err)
57 }
58
59 // create the settings directory if it does not exist
60 // XDG specifies permissions 0700 when creating settings dirs:
61 // https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
62 if err := os.MkdirAll(filepath.Dir(fname), 0700); err != nil {
63 return fmt.Errorf("failed to create settings directory: %w", err)
64 }
65
66 if err := os.WriteFile(fname, data, 0644); err != nil {
67 return fmt.Errorf("failed to write settings: %w", err)
68 }
69 return nil
70}
71
72// configMenuEntry holds information for a single config menu entry.
73type configMenuEntry struct {

Callers 3

TestSettingsFunction · 0.85
TestConfigMenuFunction · 0.85
editSettingsFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestSettingsFunction · 0.68
TestConfigMenuFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…