feature: added dir creator

master
amorozov 2024-06-30 00:54:17 +03:00
parent cf8adf9059
commit 67d71f2eef
2 changed files with 13 additions and 7 deletions

View File

@ -0,0 +1,12 @@
package files
import (
"os"
"git.tswf.io/incredible-go/incredible-go-core/pkg/io/files/file_perm"
)
func MkdirsAutoPerm(dirLocation string) error {
perm := file_perm.GetPermForDir(dirLocation)
return os.MkdirAll(dirLocation, perm)
}

View File

@ -1,15 +1,9 @@
package files package files
import (
"os"
"git.tswf.io/incredible-go/incredible-go-core/pkg/io/files/file_perm"
)
func MkdirParent(fileLocation string) error { func MkdirParent(fileLocation string) error {
parentDir := GetParentDir(fileLocation) parentDir := GetParentDir(fileLocation)
if parentDir != "" { if parentDir != "" {
parentDirCreationErr := os.MkdirAll(parentDir, file_perm.GetPermForDir(parentDir)) parentDirCreationErr := MkdirsAutoPerm(parentDir)
if parentDirCreationErr != nil { if parentDirCreationErr != nil {
return parentDirCreationErr return parentDirCreationErr