跳到主要内容

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

浏览文件

WindowsFilePublication.cs

29 行 · 1000 B历史下载
1using System.Diagnostics;
2
3namespace Cage.GuestClipboard;
4
5// Callers own both paths and finish writing their protected stage first.
6// Publish one complete snapshot while retaining the old reader and its ACL.
7internal static class WindowsFilePublication
8{
9 internal static async Task Replace(string stage,string destination,CancellationToken token)
10 {
11 var elapsed=Stopwatch.StartNew();
12 for(;;)
13 {
14 token.ThrowIfCancellationRequested();
15 try
16 {
17 if(File.Exists(destination))File.Replace(stage,destination,null);
18 else File.Move(stage,destination);
19 return;
20 }
21 catch(Exception error) when(error is IOException or UnauthorizedAccessException)
22 {
23 var code=error.HResult&0xffff;
24 if(code is not (5 or 32) || elapsed.Elapsed>=TimeSpan.FromSeconds(2))throw;
25 await Task.Delay(25,token);
26 }
27 }
28 }
29}