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

Function CopySelectedFile

utils.go:839–866  ·  view source on GitHub ↗
(selected_file []FILE_REQUEST)

Source from the content-addressed store, hash-verified

837
838
839func CopySelectedFile(selected_file []FILE_REQUEST) {
840 Copy := func(src string, dst string) {
841 src_info, err := os.Stat(src)
842 if err != nil {
843 return
844 }
845 if src_info.IsDir() {
846 if err := CopyDirectory(src, dst); err != nil {
847 return
848 }
849 } else {
850 if err := CopyFile(src, dst); err != nil {
851 return
852 }
853 }
854 }
855
856 for _, file := range selected_file {
857 if !AccessSuperPath(file.Path) {
858 // 禁止越界拷贝文件.
859 continue
860 }
861 Copy(
862 filepath.Join(SHARE_DIR, file.Path),
863 filepath.Join(SHARE_DIR, file.CurrentDir, filepath.Base(file.Path)),
864 )
865 }
866}
867
868
869// 移动被选中的文件.

Callers 1

CopyFileHandlerFunction · 0.70

Calls 3

CopyDirectoryFunction · 0.85
CopyFileFunction · 0.85
AccessSuperPathFunction · 0.85

Tested by

no test coverage detected