This commit is contained in:
2026-01-18 02:10:48 +00:00
parent 89e62ad65a
commit e9225b0018
10 changed files with 309 additions and 303 deletions
+42
View File
@@ -0,0 +1,42 @@
package filesystem
import (
"errors"
"os"
)
func CreateFile(path string, content []byte) error {
if path == "" {
return errors.New("file path cannot be empty")
}
if _, err := os.Stat(path); err == nil {
return errors.New("file already exists")
}
return os.WriteFile(path, content, 0644)
}
func CreateFolder(path string) error {
if path == "" {
return errors.New("folder path cannot be empty")
}
if _, err := os.Stat(path); err == nil {
return errors.New("folder already exists")
}
return os.Mkdir(path, 0755)
}
func DeletePath(path string) error {
if path == "" {
return errors.New("path cannot be empty")
}
if _, err := os.Stat(path); os.IsNotExist(err) {
return errors.New("path does not exist")
}
return os.RemoveAll(path)
}