MCPcopy Create free account
hub / github.com/Illusionna/LocalTransfer / MoveSelectedFile

Function MoveSelectedFile

utils.go:870–892  ·  view source on GitHub ↗

移动被选中的文件.

(selected_file []FILE_REQUEST)

Source from the content-addressed store, hash-verified

868
869// 移动被选中的文件.
870func MoveSelectedFile(selected_file []FILE_REQUEST) {
871 for _, file := range selected_file {
872 if !AccessSuperPath(file.Path) {
873 // 禁止越界移动文件.
874 continue
875 }
876
877 _, err := os.Stat(filepath.Join(SHARE_DIR, file.CurrentDir, filepath.Base(file.Path)))
878 if err != nil {
879 // 没有目标文件.
880 err := os.Rename(
881 filepath.Join(SHARE_DIR, file.Path),
882 filepath.Join(SHARE_DIR, file.CurrentDir, filepath.Base(file.Path)),
883 )
884 if err != nil {
885 continue
886 }
887 } else {
888 // 有目标文件, 跳过本次循环的移动.
889 continue
890 }
891 }
892}
893
894
895// 获取路径的文件扩展.

Callers 1

MoveFileHandlerFunction · 0.70

Calls 1

AccessSuperPathFunction · 0.85

Tested by

no test coverage detected