MCPcopy Create free account
hub / github.com/experdot/pointer / writeFileAtomically

Function writeFileAtomically

src/main/fsHandlers.ts:42–62  ·  view source on GitHub ↗
(filePath: string, content: string | Buffer)

Source from the content-addressed store, hash-verified

40}
41
42async function writeFileAtomically(filePath: string, content: string | Buffer): Promise<void> {
43 const dir = path.dirname(filePath)
44 await mkdir(dir, { recursive: true })
45
46 const tmpPath = path.join(
47 dir,
48 `.${path.basename(filePath)}.${process.pid}.${Date.now()}.${Math.random().toString(16).slice(2)}.tmp`
49 )
50
51 try {
52 await writeFile(tmpPath, content)
53 await rename(tmpPath, filePath)
54 } catch (error) {
55 try {
56 await unlink(tmpPath)
57 } catch {
58 // Ignore temp cleanup errors
59 }
60 throw error
61 }
62}
63
64export function setupFileSystemHandlers(): void {
65 // 获取应用数据目录

Callers 1

setupFileSystemHandlersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected