Louis GRIGNON
Louis GRIGNON

Reputation: 729

Cordova file plugin - copy / move directory with overwrite (recursively)

I want to move a Cordova's DirectoryEntry to another and overwrite the existing content if any. I do the following in TypeScript (same as JS):

const dir1: DirectoryEntry = await /* ... getDirectory(path1) */;
const dir2: DirectoryEntry = await /* ... getDirectory(path2) */;
dir1.moveTo(dir2, dir1.name, resolve, reject);

Both directories exist, and there is an existing directory at dir2.fullPath/dir1.name. This causes a FileError code 9: INVALID_MODIFICATION_ERR whereas I would like that the Cordova File API overwrites the existing content. Does someone please know how to do this?

The obvious workaround would be to do it manually by iterating on the DirectoryEntry/FileEntry API but this is not an option for us due to performance reasons.

Thank you for your help :)

Upvotes: 2

Views: 470

Answers (0)

Related Questions