MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / ParseFileSizeOutput

Function ParseFileSizeOutput

internal/sessions/transfer.go:262–279  ·  view source on GitHub ↗

ParseFileSizeOutput extracts a file size integer from probe command output. It strips shell metadata (exit codes, whitespace) and parses the first integer found.

(output string)

Source from the content-addressed store, hash-verified

260// ParseFileSizeOutput extracts a file size integer from probe command output.
261// It strips shell metadata (exit codes, whitespace) and parses the first integer found.
262func ParseFileSizeOutput(output string) (int, error) {
263 // Strip common shell metadata.
264 cleaned := stripShellMetadata(output)
265 cleaned = strings.TrimSpace(cleaned)
266
267 // Try to parse the first line as an integer.
268 for _, line := range strings.Split(cleaned, "\n") {
269 line = strings.TrimSpace(line)
270 if line == "" {
271 continue
272 }
273 n, err := strconv.Atoi(line)
274 if err == nil {
275 return n, nil
276 }
277 }
278 return 0, fmt.Errorf("no file size found in output: %q", output)
279}
280
281// ---------------------------------------------------------------------------
282// Output decoding

Calls 1

stripShellMetadataFunction · 0.85