MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / isDirWritable

Function isDirWritable

internal/logging/global_logger.go:119–136  ·  view source on GitHub ↗

isDirWritable checks if the specified directory exists and is writable by attempting to create and remove a test file.

(dir string)

Source from the content-addressed store, hash-verified

117
118// isDirWritable checks if the specified directory exists and is writable by attempting to create and remove a test file.
119func isDirWritable(dir string) bool {
120 info, err := os.Stat(dir)
121 if err != nil || !info.IsDir() {
122 return false
123 }
124
125 testFile := filepath.Join(dir, ".perm_test")
126 f, err := os.Create(testFile)
127 if err != nil {
128 return false
129 }
130
131 defer func() {
132 _ = f.Close()
133 _ = os.Remove(testFile)
134 }()
135 return true
136}
137
138// ResolveLogDirectory determines the directory used for application logs.
139func ResolveLogDirectory(cfg *config.Config) string {

Callers 1

ResolveLogDirectoryFunction · 0.85

Calls 3

CreateMethod · 0.80
RemoveMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected