【agent-go】- 修改文件打开指令
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"golang.org/x/net/proxy"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -14,6 +13,8 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
var RemoveForcePrefix = []string{"rm", "-rf"}
|
||||
@@ -422,26 +423,15 @@ func BasicFileExists(filename string) bool {
|
||||
// BasicFileExistAndNotNull 文件不为空返回true 文件为空返回false
|
||||
func BasicFileExistAndNotNull(filename string) bool {
|
||||
|
||||
// Check if the file exists
|
||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||
log.DebugF("文件 %s 不存在!", filename)
|
||||
// 获取文件信息
|
||||
fileInfo, err := os.Stat(filename)
|
||||
if err != nil {
|
||||
// 如果文件不存在或其他错误,返回 false
|
||||
return false
|
||||
}
|
||||
|
||||
// Open the file for reading
|
||||
file, err := os.Open(filename)
|
||||
defer file.Close()
|
||||
if err != nil {
|
||||
log.DebugF("文件 %s 打开有误!", filename)
|
||||
return false // Handle error according to your needs
|
||||
}
|
||||
|
||||
// Get the file size
|
||||
info, _ := file.Stat()
|
||||
size := info.Size()
|
||||
|
||||
// Check if the file is not empty
|
||||
return size > 0
|
||||
// 检查文件大小是否大于零
|
||||
return fileInfo.Size() > 0
|
||||
}
|
||||
|
||||
func BasicFolderExists(folderName string) bool {
|
||||
|
||||
Reference in New Issue
Block a user