添加SSL证书管理功能,包括安装、续期、列出、撤销和申请证书的命令,同时更新依赖项和修复磁盘使用情况计算逻辑。
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -474,3 +475,28 @@ func GetCurrentUserFolder() string {
|
||||
|
||||
return usr.HomeDir
|
||||
}
|
||||
|
||||
// PermissionFile 设置文件权限
|
||||
func permissionFile(filePath string, permission string) error {
|
||||
// 将字符串权限转换为 FileMode
|
||||
perm, err := strconv.ParseUint(permission, 8, 32)
|
||||
if err != nil {
|
||||
return fmt.Errorf("权限格式无效: %w", err)
|
||||
}
|
||||
return os.Chmod(filePath, os.FileMode(perm))
|
||||
}
|
||||
|
||||
// PermissionFileExecute 设置文件可执行权限
|
||||
func PermissionFileExecute(filePath string) error {
|
||||
return permissionFile(filePath, "0777")
|
||||
}
|
||||
|
||||
// PermissionFileRead 设置文件可读权限
|
||||
func PermissionFileRead(filePath string) error {
|
||||
return permissionFile(filePath, "0644")
|
||||
}
|
||||
|
||||
// PermissionFileWrite 设置文件可写权限
|
||||
func PermissionFileWrite(filePath string) error {
|
||||
return permissionFile(filePath, "0666")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user