(function () { /* ---------------------Single commands--------------------- */ /* Create a directory */ p7.commands.createDirectory = async (name, fileSystem) => await p7.send.singleCommand(flashCommandSubtype.createDirectory, 0, 0, [name, '', '', '', fileSystem, '']); /* Delete a directory */ p7.commands.deleteDirectory = async (name, fileSystem) => await p7.send.singleCommand(flashCommandSubtype.deleteDirectory, 0, 0, [name, '', '', '', fileSystem, '']); /* Rename a directory */ p7.commands.renameDirectory = async (oldName, newName, fileSystem) => await p7.send.singleCommand(flashCommandSubtype.renameDirectory, 0, 0, [oldName, newName, '', '', fileSystem, '']); /* Change working directory */ p7.commands.changeDirectory = async (name, fileSystem) => await p7.send.singleCommand(flashCommandSubtype.changeDirectory, 0, 0, [name, '', '', '', fileSystem, '']); /* Delete a file */ p7.commands.deleteFile = async (directory, name, fileSystem) => await p7.send.singleCommand(flashCommandSubtype.deleteFile, 0, 0, [directory, name, '', '', fileSystem, '']); /* Rename a file */ p7.commands.renameFile = async (directory, oldName, newName, fileSystem) => await p7.send.singleCommand(flashCommandSubtype.renameFile, 0, 0, [directory, oldName, newName, '', fileSystem, '']); /* Copy a file */ p7.commands.copyFile = async (oldDirectory, oldName, newDirectory, newName, fileSystem) => await p7.send.singleCommand(flashCommandSubtype.copyFile, 0, 0, [oldDirectory, oldName, newDirectory, newName, fileSystem, '']); /* Optimize fileSystem */ p7.commands.optimizeFileSystem = async (fileSystem) => await p7.send.singleCommand(flashCommandSubtype.optimizeFileSystem, 0, 0, ['', '', '', '', fileSystem, '']); /* ---------------------Single command requests--------------------- */ /* List files */ p7.commands.list = async function (fileSystem) { let fileList = []; try { (await p7.send.singleCommandRoleswap(flashCommandSubtype.fileInfoTransferAllRequest, 0, 0, ['', '', '', '', fileSystem, ''])) .forEach(element => fileList.push({ size: element.fileSize, DirectoryName: element.data[0], name: element.data[1] }) ); } catch (err) { throw new Error("Couldn't list files: " + err.message); } return fileList; } }) ();