Important: Please read the Qt Code of Conduct -

QtIFW: How to use the Operation "Move"

  • Hi,

    i want to move files after extracing from archive. Whatever i try, it will not work.

    First, there seems to be a mistake in the documentation:

    Adding Operations to Components

    You might want to add custom operations after extracting the content, when copying files or patching file content, for example. You can create and add update operations to the installation from within a script using component::addOperation(). If you need to run an operation that requires administrative rights, use component::addElevatedOperation() instead.

    Operations need to be added before the actual installation step. Override component::createOperations() to register custom operations for a component.

    I want to copy or mov efiles after extracting the content. So i override the component::createOperations() and call component.addOperation();

    Component.prototype.createOperations = function()
    	installer.performOperation("Mkdir", "@TargetDir@/lol");	
    	var dir = installer.value("TargetDir");	
    	QMessageBox.information("asasas", "asasa", "Exists " + installer.fileExists(dir + "/foo.txt"), QMessageBox.Ok);	// FALSE
    	installer.performOperation("Move", dir + "/foo.txt", dir + "/lol/");	
    	QMessageBox.information("asasas", "asasa", "Exists " + installer.fileExists("C:/Users/hschenk/lol.txt"), QMessageBox.Ok);	
    	installer.performOperation("Move", "C:/Users/hschenk/lol.txt", "C:/Users/hschenk/lalalala/"); //*already created before the setup	

    The problem is that the file foo.txt does not exists at the moment i call "Move".

    The second Problem is that the operation move does not really work. No matter how i call the command the lol.txt disappear and is not ion the directory lalalala

    How can i fix both problems? Can you give me an example?

    Thank you in advance.

  • @Schenk

    This is more a user driven forum and answering on IFW posts is typically slow, if there is an answer at all.

    Your question is very detailed and goes beyond the typical issues here. Therefore, I would recommend to ask the question on the developer mailing list

  • Ehm..ok ;)

  • @Schenk
    I just tried with it. works fine.
    You should use addOperation insted of performOperation

    component.fileWithRegisteredType = installer.value("TargetDir") + "/Test/TESSSST.txt";
    component.addOperation("Move", "@TargetDir@/test.txt", component.fileWithRegisteredType);

    Ref :

  • @Ratzz What do you do? Do you rename a file? TESSSST.txt to test.txt?

    Can you give me an example how to mov ea file to another folder?

    UPDATE: GOT IT! ;)

    -- /lola
    -- foo.txt

    component.fileWithRegisteredType = installer.value("TargetDir") + "/lola/lol/foo.txt";
    component.addOperation("Move", "@TargetDir@/lola/foo.txt", component.fileWithRegisteredType);

    -- /lola
    -- foo.txt

  • @Schenk said in QtIFW: How to use the Operation "Move":

    What do you do?

    Move a file present in the installer to a path(or folder) you want after installation.

    Do you rename a file?

    No. It was a test case u can still give your text file name.

Log in to reply