|
|
#1 |
|
Junior Member
Join Date: May 2007
Posts: 6
|
Hello All,
I want to make a backup copy of file only in case when it is different from installed version and then overwrite it. Here is a macro I wrote to do this: code: but generally it does not work. File time is always different (event after reinstall), existing .old files are not deleted and rename in this case does not work, File command says skipped even when file time read from GetFileTime and GetFileTimeLocal is different. For me coding looks correct and I dont know what to check more. Maybe some has idea how to make this working or maybe better solutions for backup of files which differ exist? Thanks a lot for help! Regards, Kefira |
|
|
|
|
|
#2 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
What about this xml file?
Is it dynamically created at runtime and/or writing/updating it at application usage? Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: May 2007
Posts: 6
|
No this is normal static file, not dynamically created, which contais configuration for xml highlighting in my editor.
File is not chnaged during script execution. No file attributes changed also. I think result would be the same for any other file. The installation log can looks like this: code: |
|
|
|
|
|
#4 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
Well, wouldn't be easier to add an entry in the file which identifies its version so reading this entry e.g. in function .onInit would allow you to backup the file if necessary?
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: May 2007
Posts: 6
|
No. I dont think that this is a solution, because file can be changed by user manually, and he whould not think about increasing of some "version". Last modified date is most suitable thing, because it changes allways and as I have noticed NSIS would set date/time of installed file as date/time of original.
The idea is to not overwrite user changes in configuration files and merge them, on first start of updated application, with updated configuration file. |
|
|
|
|
|
#6 |
|
Forum King
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
|
hmm, I think you're using improperly the GetFileTimeLocal instruction, probably you need to run another script which generates a header with those 2 values as defines.
Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: May 2007
Posts: 6
|
And what is correct usage for this function?
What I have found with it, that GetFileTimeLocal does not accept any variable as file name. It only works when it is inline string or macro with inline string.. Using of the external tool for generating of time stamp would be rather complicated, because I need to do this for all (more then 30) configuration fles which are installed... |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
I don't see a problem with the way you use GetFileTimeLocal. It won't allow a variable for the file name or path because it executes strictly during compile time, when the variables don't yet have any values.
Are you installing onto the same type of file system as the setup is built on (NTFS or FAT32 for both)? The file times depend upon the resolution of the file system; it looks like the LOW word differs by about a half second for the two files - close enough that the FS could be the cause. Don |
|
|
|
|
|
#9 |
|
Junior Member
Join Date: May 2007
Posts: 6
|
Hello Don,
The installation is executed in the same machine where it is build. From drive D to drive C, both have NTFS, on XP. The strange thing you can see in the log: LOW_LOCAL=1979421442 not equal LOW=1973640192 Skipped: xml_spec.xml The File function skipes copying, but time low time is different, and this is when overwrite settings for File is ifdiff. Regards, Kefir |
|
|
|
|
|
#10 |
|
Senior Member
Join Date: Mar 2006
Location: Dallas
Posts: 462
|
Someone familiar with the NSIS source might be a better person to provide this answer, but it looks like NSIS expects the file time to have no better than 2 seconds resolution, and any difference less than that is considered to be matching times. Your file times differ by 0.58 seconds, so the script thinks they match and it skips the extraction of the new one.
The GetFileTime / GetFileTimeLocal commands give you the Windows FILETIME data type, the number of seconds since 1/1/1601, expressed in units of 100 nanoseconds. The low word only goes up to (2^32 / 10^7 seconds, about 4 minutes); put a decimal point in the value with 7 digits to the right of it: 1979421442 -> 197.9421442. Since both the target and the build file times' low words start 197..., the difference is less than one second. Don |
|
|
|
|
|
#11 | |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
Quote:
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
|
#12 |
|
Junior Member
Join Date: May 2007
Posts: 6
|
Hello guys,
thanks a lot for help! This description helps to make working solution. I have corrected the script to skip changes if time difference less then 3 seconds (to be safe ). I submit it here, maybe would be helpful to somebody.PHP Code:
PHP Code:
Kefir. |
|
|
|
|
|
#13 |
|
Junior Member
Join Date: Jun 2007
Posts: 3
|
work around for 2 second file modified date resolution
Is there any way to work around the 2 second resolution of file modified dates? I'm creating a CD installer for a Java WebStart application, which compares the file dates with ones on a web server to see if an update is required. The problem I'm having is that the installer is setting the file date on one of the files to Friday, June 15, 2007, 11:22:04 PM but the original file date was Friday, June 15, 2007, 11:22:05 PM... this causes the auto update feature of Java Web Start to kick in every time... negating the benefits of an off line CD install.
If it helps, here's the relevant portion of the script: PHP Code:
As an alternate solution, is there a way to get the drive letter of the CD the installer is running from? I'm sure this is a n00b question, so I apologize if this question has been answered before... Any help would be greatly appreciated! Thanks, Nick |
|
|
|
|
|
#14 |
|
M.I.A.
[NSIS Dev, Mod] Join Date: Oct 2001
Location: Israel
Posts: 11,343
|
You could use $EXEDIR to get the directory where the installer is located. You can then use GetRoot to get the root drive of that directory.
NSIS FAQ | NSIS Home Page | Donate $ "I hear and I forget. I see and I remember. I do and I understand." -- Confucius |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Jun 2007
Posts: 3
|
Exactly what I needed. thanks! Kinda out of place, but if it helps anyone else, here's the modified code:
PHP Code:
|
|
|
|
|
|
#16 |
|
Junior Member
Join Date: Jun 2007
Posts: 3
|
Oops, the slashes went away in my last post
PHP Code:
|
|
|
|
|
|
#17 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Use [code] not [php]
![]() Stu |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|