MCPcopy
hub / github.com/caddyserver/caddy / mkdirAllFromFile

Function mkdirAllFromFile

modules/logging/filewriter.go:345–351  ·  view source on GitHub ↗

mkdirAllFromFile creates missing dirs using the file's mode (with r→x) so 0644 → 0755, 0600 → 0700, etc.

(dir string, fileMode os.FileMode)

Source from the content-addressed store, hash-verified

343// mkdirAllFromFile creates missing dirs using the file's mode (with r→x) so
344// 0644 → 0755, 0600 → 0700, etc.
345func mkdirAllFromFile(dir string, fileMode os.FileMode) error {
346 if fi, err := os.Stat(dir); err == nil && fi.IsDir() {
347 return nil
348 }
349 perm := normalizeDirPerm(fileMode.Perm()) | 0o200 // ensure owner write on dir so files can be created
350 return os.MkdirAll(dir, perm)
351}
352
353// UnmarshalCaddyfile sets up the module from Caddyfile tokens. Syntax:
354//

Callers 1

OpenWriterMethod · 0.85

Calls 2

normalizeDirPermFunction · 0.85
StatMethod · 0.80

Tested by

no test coverage detected