跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

storage_default.go

39 行 · 1.1 KB历史下载
1package cage
2
3import (
4 "os"
5 "path/filepath"
6 "runtime"
7 "strings"
8)
9
10// InitialStorageDirectory supplies a fresh packaged Windows installation's
11// data location. Profiles and existing storage records keep their own paths.
12func InitialStorageDirectory(exe string) string {
13 resolved, err := filepath.EvalSymlinks(exe)
14 if err != nil {
15 return ""
16 }
17 return initialStorageDirectory(resolved, runtime.GOOS)
18}
19
20func initialStorageDirectory(exe, platform string) string {
21 if platform != "windows" || !strings.EqualFold(filepath.Base(filepath.Dir(exe)), "resources") {
22 return ""
23 }
24 return windowsApplicationDataDirectory(filepath.Dir(filepath.Dir(exe)), platform)
25}
26
27func windowsApplicationDataDirectory(app, platform string) string {
28 if platform != "windows" {
29 return ""
30 }
31 marker, err := os.ReadFile(filepath.Join(app, "Cage.install-id"))
32 if err != nil || string(marker) != "io.github.lee-xeo.claude-cage" {
33 return ""
34 }
35 if info, err := os.Stat(filepath.Join(app, "Cage.exe")); err != nil || !info.Mode().IsRegular() {
36 return ""
37 }
38 return filepath.Join(app, "CageData")
39}