MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / renameFile

Function renameFile

src/fileSystem/internalFs.js:131–152  ·  view source on GitHub ↗

* Rename a file or directory * @param {string} url * @param {string} newname * @returns {Promise}

(url, newname)

Source from the content-addressed store, hash-verified

129 * @returns {Promise}
130 */
131 renameFile(url, newname) {
132 return new Promise((resolve, reject) => {
133 reject = setMessage(reject);
134 window.resolveLocalFileSystemURL(
135 url,
136 (fs) => {
137 fs.getParent((parent) => {
138 fs.moveTo(
139 parent,
140 newname,
141 async (entry) => {
142 const newUrl = Url.join(Url.dirname(url), entry.name);
143 resolve(newUrl);
144 },
145 reject,
146 );
147 }, reject);
148 },
149 reject,
150 );
151 });
152 },
153
154 /**
155 * Create a directory

Callers

nothing calls this directly

Calls 3

resolveFunction · 0.85
setMessageFunction · 0.70
moveToMethod · 0.45

Tested by

no test coverage detected