mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-05-19 18:58:03 +02:00
12436217ae
* feat: add filemanager session and crypto version detection * refactor: move copy logic into filemanager, remove fileutil dependency * fix: apply review suggestions for filemanager * feat: add Windows locked file tests, fix readFileContent with ReadFile+FileMapping fallback * fix: remove self-PID skip in findFileHandle to fix Windows CI test * fix: seek to file start before reading duplicated handle * fix: use full path matching in findFileHandle to avoid cross-app handle collision * test: enhance Windows copyLocked tests with write-then-read, large file, and normal copy scenarios * fix: check all errors in Windows tests, use bytes.Equal for large file comparison * fix: use stable path suffix matching to handle Windows short path names in CI
36 lines
816 B
Go
36 lines
816 B
Go
package filemanager
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
cp "github.com/otiai10/copy"
|
|
)
|
|
|
|
// copyFile copies a single file from src to dst.
|
|
func copyFile(src, dst string) error {
|
|
data, err := os.ReadFile(src)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return os.WriteFile(dst, data, 0o600)
|
|
}
|
|
|
|
// copyDir copies a directory from src to dst, skipping files
|
|
// whose path ends with the skip suffix (e.g. "lock").
|
|
func copyDir(src, dst, skip string) error {
|
|
opts := cp.Options{Skip: func(info os.FileInfo, src, _ string) (bool, error) {
|
|
return strings.HasSuffix(strings.ToLower(src), skip), nil
|
|
}}
|
|
return cp.Copy(src, dst, opts)
|
|
}
|
|
|
|
// isFileExists checks if a file (not directory) exists at the given path.
|
|
func isFileExists(path string) bool {
|
|
info, err := os.Stat(path)
|
|
if err != nil {
|
|
return false
|
|
}
|
|
return !info.IsDir()
|
|
}
|