MCPcopy Create free account
hub / github.com/Noumena-Network/code / writeAtomically

Function writeAtomically

src/shims/nativeAssetRuntime.ts:25–33  ·  view source on GitHub ↗
(targetPath: string, content: Buffer, mode?: number)

Source from the content-addressed store, hash-verified

23}
24
25function writeAtomically(targetPath: string, content: Buffer, mode?: number): void {
26 mkdirSync(dirname(targetPath), { recursive: true })
27 const temporaryPath = `${targetPath}.tmp.${process.pid}`
28 writeFileSync(temporaryPath, content)
29 if (mode !== undefined) {
30 chmodSync(temporaryPath, mode)
31 }
32 renameSync(temporaryPath, targetPath)
33}
34
35function sanitizeGroupKey(groupKey: string): string {
36 return groupKey.replace(/[^a-zA-Z0-9._-]+/g, '-')

Callers 1

Calls 2

mkdirSyncFunction · 0.85
renameSyncFunction · 0.85

Tested by

no test coverage detected