MCPcopy Create free account
hub / github.com/gokcehan/lf / loadFiles

Function loadFiles

app.go:119–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117}
118
119func loadFiles() (clipboard clipboard, err error) {
120 files, err := os.Open(gFilesPath)
121 if os.IsNotExist(err) {
122 err = nil
123 return
124 }
125 if err != nil {
126 err = fmt.Errorf("opening file selections file: %w", err)
127 return
128 }
129 defer files.Close()
130
131 s := bufio.NewScanner(files)
132
133 if !s.Scan() {
134 err = fmt.Errorf("scanning file list: %w", cmp.Or(s.Err(), io.EOF))
135 return
136 }
137
138 switch s.Text() {
139 case "copy":
140 clipboard.mode = clipboardCopy
141 case "move":
142 clipboard.mode = clipboardCut
143 default:
144 err = fmt.Errorf("unexpected option to copy file(s): %s", s.Text())
145 return
146 }
147
148 for s.Scan() && s.Text() != "" {
149 clipboard.paths = append(clipboard.paths, s.Text())
150 }
151
152 if s.Err() != nil {
153 err = fmt.Errorf("scanning file list: %w", s.Err())
154 return
155 }
156
157 log.Printf("loading clipboard: %v", clipboard.paths)
158
159 return
160}
161
162func saveFiles(clipboard clipboard) error {
163 for _, path := range clipboard.paths {

Callers 2

pasteMethod · 0.85
syncMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected