跳到主要内容

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

浏览文件

windows_storage_windows.go

51 行 · 1.3 KB历史下载
1//go:build windows
2
3package guestos
4
5import (
6 "context"
7 "errors"
8 "os"
9 "path/filepath"
10
11 "github.com/google/uuid"
12 "golang.org/x/sys/windows"
13)
14
15func windowsHostStorage(ctx context.Context, id uuid.UUID, input windowsHostStorageRequest) (windowsHostStorageState, error) {
16 var state windowsHostStorageState
17 err := windowsHostManagerRequestCall(ctx, windowsHostManagerRequest{Version: windowsHostManagerVersion, VMID: id, Operation: "storage", Storage: &input}, &state)
18 return state, err
19}
20
21func WindowsPrivateStoragePaths() []string {
22 return []string{filepath.Join(managerKnownFolder(windows.FOLDERID_ProgramData), "Cage", "HyperVManager")}
23}
24
25func replaceWindowsStorageProfile(path string, data []byte) error {
26 file, err := os.CreateTemp(filepath.Dir(path), ".windows-storage-*")
27 if err != nil {
28 return err
29 }
30 defer os.Remove(file.Name())
31 if err = protectWindowsProfile(file.Name()); err != nil {
32 file.Close()
33 return err
34 }
35 _, err = file.Write(data)
36 if err == nil {
37 err = file.Sync()
38 }
39 if err = errors.Join(err, file.Close()); err != nil {
40 return err
41 }
42 from, err := windows.UTF16PtrFromString(file.Name())
43 if err != nil {
44 return err
45 }
46 to, err := windows.UTF16PtrFromString(path)
47 if err != nil {
48 return err
49 }
50 return windows.MoveFileEx(from, to, windows.MOVEFILE_REPLACE_EXISTING|windows.MOVEFILE_WRITE_THROUGH)
51}