×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    228

    Question How to create a folder on install and delete it on uninstall?

    Hi all,

    I want to ask how to create a folder in N9 device (hidden if possible) and add some files related to my application to it when installing.
    also i need that file to be removed when uninstalling the application.

    any help??

    Thank you
    Rondo

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: How to create a folder on install and delete it on uninstall?

    Don't know about the hidden property can be there for a folder or not but for deploying folder while the application is installing , keyword DEPLOYMENTFOLDERS can be used in.pro file which contains the folder to be deployed.And though its not hidden but its for sure that it cannot be deleted manually. Also you can add files in that folder only & that whole folder will be deployed while installing For e.g in .pro file:


    folder_01.source = source path for folder(from your project directory)
    folder_01.target = target path for folder
    DEPLOYMENTFOLDERS = folder_01

  3. #3
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    228

    Re: How to create a folder on install and delete it on uninstall?

    Quote Originally Posted by vineet.jain View Post
    Don't know about the hidden property can be there for a folder or not but for deploying folder while the application is installing , keyword DEPLOYMENTFOLDERS can be used in.pro file which contains the folder to be deployed.And though its not hidden but its for sure that it cannot be deleted manually. Also you can add files in that folder only & that whole folder will be deployed while installing For e.g in .pro file:


    folder_01.source = source path for folder(from your project directory)
    folder_01.target = target path for folder
    DEPLOYMENTFOLDERS = folder_01
    Hi thank you for your reply

    i have added the following into my project file

    folder_01.source = qml/qml
    folder_01.target = qml
    DEPLOYMENTFOLDERS = folder_01

    suppose that i have an image in the folder qml(test.jpg)..if i call this image directly from qml it works well(for ex: iconSource: "test.jpg")
    but i want to use that test.jpg from my C++ , i cant find a way to do it!! what should be the path for it?

    what i did now is to add the file in the home path as the following
    QString path(QDir::home().path());
    path.append(QDir::separator()).append("test.jpg");
    path = QDir::toNativeSeparators(path);
    and use the path of the image..but this file isnt removed when i uninstall the application and it can be deleted from the user even if still use application
    so how to solve that?
    where should be the path of my folder and how to use that data? also this folder is deleted when uninstalling the app?

    Thank you
    Rondo

  4. #4
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: How to create a folder on install and delete it on uninstall?

    Well you can specify the absolute path of the file for use in c++ code. Let say you keep the file in a folder created inside the qml folder only(say images) then to access the same in your c++ code, the path would be:

    /opt/appname/qml/appname/ImageFolder/Image123.jpg

    keeping the files in this path , though the files cannot be deleted & they would by default be uninstalled as well, but it is not advisable to read files from here.

    The path you used is correct way of keeping files(the home path) & i am sure there is a way exists to remove the files at the time of uninstall(just that i am unable to search it right now)

  5. #5
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: How to create a folder on install and delete it on uninstall?

    For deleting files on installation you can write a postrm or prerm script and put in dir qtc_packaging/debian_harmattan

    http://www.debian.org/doc/debian-pol...erscripts.html

  6. #6
    Nokia Developer Moderator
    Join Date
    Mar 2009
    Posts
    1,024

    Re: How to create a folder on install and delete it on uninstall?

    If the directory is installed by the debian package you don't need to specify any postrm/prerm script.

  7. #7
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    228

    Re: How to create a folder on install and delete it on uninstall?

    @vineet.jain: Thank you for ur reply, i used the absolute path and it worked successfully without any error, but can u please guide me more why reading files from that path is not advisable?

    @kusumk:i read that link , but didnt get it how to use it..what should be the file name? what is his extension? how to call it? where do i add functions to call it? sorry for my ignorance about it

    @gnuton: i have already added the option "Install Debian package to sysroot" and "Deploy Debian package via SFTP upload using device" from Qt Creator , the files found in the absolute path /opt/appname/qml/appname are deleted when uninstalling the application, but my problem is that i am adding some files to the devices from my application( as logs for example) these files are not deleted when uninstalling my application..what i want is to remove all related data of the application while uninstalling

    Thank you

  8. #8
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: How to create a folder on install and delete it on uninstall?

    Hi,

    >>@kusumk:i read that link , but didnt get it how to use it..what should be the file name? what is his extension? how to call it? where do i add functions to call it? sorry for my ignorance about it

    Ok. They are called debian maintainer scripts. These scripts are like normal shell scripts. The script has to start with #!/bin/bash

    names are postinst, preinst, prerm, postrm. All of them are optional. You would use each of them only when needed. These are placed in the debian_harmattan folder as mentioned earlier.

    preinst - this script is executed prior to the installation of the package.

    postinst - this script is executed after the installation of the package.

    prerm - this script is executed prior to the un-installation of the package.

    postrm - this script is executed after the un-installation of the package.

    In your case you would place something like this in prerm or postrm script, depending on when you want it to be executed -

    #! /bin/sh
    rm -rf /home/user/demo.txt

    So from your queries, now you know how to name the files. they do not have extensions, they need not be explicitly called.

    They are taken care of by the dpkg tool when you uninstall your package. You need not do anything.

    Hope this helps!

  9. #9
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: How to create a folder on install and delete it on uninstall?

    Quote Originally Posted by Rondo23 View Post
    @vineet.jain: Thank you for ur reply, i used the absolute path and it worked successfully without any error, but can u please guide me more why reading files from that path is not advisable?
    Well my purpose was saying this was that you won't be able to modify anything at this path(/opt/appname/..) as adding/deleting files to this path are not allowed on runtime.Though i have to admit, you can read the files from here.

    Any file/folder which is deployed at installation time though debian package is deleted at uninstall time but at the same time you cannot modify those files/folder.

    And yes for log files which you would be making at runtime , you have to create a separate folder which of course is not deleted on uninstalling the application.

  10. #10
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    228

    Re: How to create a folder on install and delete it on uninstall?

    Sorry for beeing late,

    thank you all for your help
    problem solved with using prerm to remove my files..thank you kusumk
    and thank you vineet.jain too, i will use the home path to add my files

    Regards,
    Rondo

Similar Threads

  1. Replies: 31
    Last Post: 2007-08-14, 05:21
  2. delete files on uninstall
    By Bill_Murray in forum Symbian C++
    Replies: 4
    Last Post: 2007-06-20, 15:37
  3. App private folder & uninstall 3rd Ed
    By l0rdpwr in forum Symbian C++
    Replies: 3
    Last Post: 2006-12-08, 12:40
  4. How to delete/uninstall application from emulator
    By vardhman in forum Symbian C++
    Replies: 3
    Last Post: 2004-09-03, 08:01
  5. How to delete my files When my Apps Uninstall?
    By kangtk in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2002-12-09, 12:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •