MCPcopy Create free account
hub / github.com/EvoMap/evolver / canMakeDirReadOnly

Function canMakeDirReadOnly

test/helpers/symlink.js:67–90  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65let _cachedReadOnlyDir;
66
67function canMakeDirReadOnly() {
68 if (_cachedReadOnlyDir !== undefined) return _cachedReadOnlyDir;
69 let dir;
70 try {
71 dir = fs.mkdtempSync(path.join(os.tmpdir(), 'evolver-rodir-probe-'));
72 fs.chmodSync(dir, 0o555);
73 try {
74 fs.writeFileSync(path.join(dir, 'write-probe'), 'x');
75 // Write succeeded — chmod did not actually enforce read-only.
76 _cachedReadOnlyDir = false;
77 } catch {
78 // Write failed as expected — chmod is honoured.
79 _cachedReadOnlyDir = true;
80 }
81 } catch {
82 _cachedReadOnlyDir = false;
83 } finally {
84 if (dir) {
85 try { fs.chmodSync(dir, 0o755); } catch {}
86 try { fs.rmSync(dir, { recursive: true, force: true }); } catch {}
87 }
88 }
89 return _cachedReadOnlyDir;
90}
91
92module.exports = { canCreateSymlinks, canMakeDirReadOnly };

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected