|
@@ -11,6 +11,7 @@ import ( |
|
|
"log" |
|
|
"log" |
|
|
"os" |
|
|
"os" |
|
|
"os/exec" |
|
|
"os/exec" |
|
|
|
|
|
"path" |
|
|
"path/filepath" |
|
|
"path/filepath" |
|
|
"strconv" |
|
|
"strconv" |
|
|
"strings" |
|
|
"strings" |
|
@@ -477,14 +478,87 @@ func copyAndCapture(w io.Writer, r io.Reader, progress chan string) ([]byte, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
运行变更生效 |
|
|
|
|
|
|
|
|
单个文件信息 |
|
|
|
|
|
*/ |
|
|
|
|
|
type simpleFileInfo struct { |
|
|
|
|
|
Name string `json:"name" ` |
|
|
|
|
|
Extension string `json:"extension"` |
|
|
|
|
|
RelativePath string `json:"relativePath"` |
|
|
|
|
|
AbsolutePath string `json:"absolutePath"` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var gobalFolderFileMap = make(map[string] *simpleFileInfo) |
|
|
|
|
|
var gobalRelativePath string |
|
|
|
|
|
/** |
|
|
|
|
|
获取指定目录或文件的文件信息,如果是目录递归获取文件信息 |
|
|
@param id 文件id |
|
|
@param id 文件id |
|
|
*/ |
|
|
*/ |
|
|
func NotifyFileChange(id string, changeType int){ |
|
|
|
|
|
|
|
|
func GetFolderFileInfo(conn *websocket.Conn,absolutePath string) error{ |
|
|
|
|
|
|
|
|
|
|
|
fileInfo,err :=os.Stat(absolutePath) |
|
|
|
|
|
if err!=nil{ |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
log.Println(filepath.Dir(absolutePath)) |
|
|
|
|
|
//单个文件处理 |
|
|
|
|
|
|
|
|
|
|
|
if !fileInfo.IsDir() { |
|
|
|
|
|
simpleFileInfo := new(simpleFileInfo) |
|
|
|
|
|
simpleFileInfo.Name=fileInfo.Name() |
|
|
|
|
|
simpleFileInfo.Extension=path.Ext(absolutePath) |
|
|
|
|
|
simpleFileInfo.RelativePath="" |
|
|
|
|
|
simpleFileInfo.AbsolutePath=absolutePath |
|
|
|
|
|
gobalFolderFileMap[absolutePath]=simpleFileInfo |
|
|
|
|
|
bytes,err :=json.Marshal(gobalFolderFileMap) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
if err := conn.WriteMessage(websocket.TextMessage, bytes); err != nil { |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//文件目录处理 |
|
|
|
|
|
gobalRelativePath = filepath.Dir(absolutePath)+"\\" |
|
|
|
|
|
err =filepath.Walk(absolutePath, myWalkfunc) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bytes,err :=json.Marshal(gobalFolderFileMap) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
if err := conn.WriteMessage(websocket.TextMessage, bytes); err != nil { |
|
|
|
|
|
log.Println(err) |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func myWalkfunc(path string, info os.FileInfo, err error) error { |
|
|
|
|
|
|
|
|
|
|
|
if info.IsDir()==false{ |
|
|
|
|
|
simpleFileInfo := new(simpleFileInfo) |
|
|
|
|
|
simpleFileInfo.Name=info.Name() |
|
|
|
|
|
simpleFileInfo.Extension=filepath.Ext(path) |
|
|
|
|
|
simpleFileInfo.RelativePath=strings.Replace(path,gobalRelativePath,"",1) |
|
|
|
|
|
simpleFileInfo.AbsolutePath=path |
|
|
|
|
|
gobalFolderFileMap[path]=simpleFileInfo |
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
获取本地文件列表 |
|
|
获取本地文件列表 |
|
|