Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Posts
    18

    Backup file location

    I have a line in the OnPreInstall event that sets my backup file location as follows:

    -- Set the location of backup files
    _BackupFolder = SessionVar.Expand("%AppFolder%\\sufBackup");


    That works fine and the files listed in the archive are backed up to this folder when the approriate option is ticked. I also have the following code in the On Post Install event:

    local result = File.Install(appPath .. sourceFile,
    appPath .. destFile,
    FILE_INSTALL_SAMEOLDER,
    true,
    false,
    nil,
    nil);
    File.Delete(appPath .. sourceFile, false, false, false, nil);


    This installs a file with a new name, so allowing me to effectively rename a file during the install. In the options to File.Install I have requested that the file be backed up before the copy. This gives me two issues:
    1. The backup is placed in the same folder as the file, NOT the backup folder I requested.
    2. The backup is of the SOURCE file, not the one I'm overwriting. That seems a little pointless as, surely, the file to be backed up should be the one you're about to overwrite.

    Any way I can change this behaviour?

    Thanks
    Steve

  2. #2
    Join Date
    May 2000
    Location
    Indigo Rose Software
    Posts
    2,150
    Just to update everyone on this because we have been dealing with it through support. The File.Install() is backing up the target file properly but because the source and target are using different names it is backing up the target file but giving it the source files name.

    Adam Kapilik

  3. #3
    Join Date
    Sep 2007
    Posts
    18
    To add a little context. Our file naming standards require that updated modules include the version number in the file name. So, for example, version 3.6.23 of the ipmeuk.dll file would be called ipmeuk_3623.dll. This is the file that gets included in the install.

    SUF does not allow me to install the file with a different name, so I have to rename it after the install. File.Install() seemed to do this for me, but I hit two problems; the name of the backup file is taken from the source file and the backup is not written to the same location as the automatic backup files - it goes to the same folder as the target file.

    To get round this, I have developed the following script. It's not 100% in that it assumes that the user will never delete some of their backup files; they either leave them alone or they delete them all. I could add more sophisticated code to determine the next backup file name, but I'm doing an evaluation, so my scripting skills are very much 'new' and time is of the essence if I'm going to test everything I need to.

    Still, the code may prove useful to someone else:

    -- Function to rename a file - install it with the new name and
    -- then delete the source file.
    function RenameAppFile(appPath, sourceFile, destFile)
    -- appPath = The folder containing the source and target files
    -- sourceFile = The name of the file to rename
    -- destFile = The name of the file to create

    SetupData.WriteToLogFile("Renaming " .. sourceFile .. " to " .. destFile .. "\r\n", true);

    local backupFiles = File.Find(_BackupFolder, destFile .. ".b*", false, false);
    if backupFiles ~= nil then
    backupName = _BackupFolder .. destFile .. ".bk" .. Table.Count(backupFiles);
    else
    backupName = _BackupFolder .. destFile .. ".bak";
    end

    -- Backup the file.
    File.Copy(appPath .. destFile, backupName, false, true);
    SetupData.WriteToLogFile("Backup file created: " .. backupName .. "\r\n", true);

    local result = File.Install(appPath .. sourceFile,
    appPath .. destFile,
    FILE_INSTALL_SAMEOLDER,
    false,
    false,
    nil,
    nil);

    -- Delete the installed file - we no longer need it.
    File.Delete(appPath .. sourceFile, false, false, false, nil);

    -- Setup for th e uninstall process, so we restore the backup file.
    ItemData = {
    Filename = appPath .. destFile,
    DecrementUsageCount = true,
    UnregisterCOM = false,
    UnregisterFont = false,
    BackupFile = backupName
    }
    UninstallData.AddItem(UNINDATA_FILES, ItemData);

    return;
    end


    You would call this function as follows:

    -- The install file is called ipmeuk_3623.dll. The runtime file is
    -- called ipmeuk.dll so we need to rename it.
    RenameAppFile(appFolder, "\\ipmeuk_3623.dll", "\\ipmeuk.dll");

    HTH
    Steve

Similar Threads

  1. Best way to share custom buttons with the group?
    By mwreyf1 in forum AutoPlay Media Studio 6.0
    Replies: 10
    Last Post: 04-28-2010, 01:29 PM
  2. Error 3038: Could not seek in compressed file
    By Rikard in forum Setup Factory 7.0
    Replies: 2
    Last Post: 05-25-2006, 11:55 AM
  3. Can search allow manual browse even if file is found?
    By RichardShaw in forum Setup Factory 5.0
    Replies: 2
    Last Post: 08-28-2000, 06:08 PM
  4. Replies: 0
    Last Post: 08-17-2000, 02:29 PM

Posting Permissions

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