MCPcopy Create free account
hub / github.com/Crain99/cc-reverse / copyFile

Function copyFile

src/utils/fileManager.js:133–162  ·  view source on GitHub ↗

* 复制文件 * @param {string} source 源文件路径 * @param {string} target 目标文件路径 * @returns {Promise }

(source, target)

Source from the content-addressed store, hash-verified

131 * 递归删除目录
132 * @param {string} directory 要删除的目录
133 * @returns {Promise<void>}
134 */
135 async cleanDirectory(directory) {
136 try {
137 if (!fs.existsSync(directory)) {
138 return;
139 }
140 await fsp.rm(directory, { recursive: true, force: true });
141 logger.debug(`删除目录: ${directory}`);
142 } catch (err) {
143 logger.error(`删除目录 ${directory} 时出错:`, err);
144 throw err;
145 }
146 },
147};
148
149/**
150 * JSON.stringify that breaks cycles instead of throwing.
151 * Already-seen objects become {"__circular__": true}.
152 * Prefer resourceProcessor.toIdReferencedArray for Cocos scene graphs.
153 */
154function safeJsonStringify(value, space = 2) {
155 const seen = new WeakSet();
156 return JSON.stringify(
157 value,
158 (key, val) => {
159 if (val && typeof val === 'object') {
160 if (seen.has(val)) {
161 return { __circular__: true };
162 }
163 seen.add(val);
164 }
165 return val;

Callers 3

unpackBundleFunction · 0.50
unpackAssetFunction · 0.50
recoverScriptsFunction · 0.50

Calls 1

resolveFunction · 0.85

Tested by

no test coverage detected