Archive: Copy file name truncated


Copy file name truncated
Hi,

Following code extract produces two errors on my system:


!define PRODUCT_BACKGROUND_ORIG "background_mon.jpg"
!define PRODUCT_BACKGROUND "background.jpg"

Section "Application" SEC01
StrCmp "${PRODUCT_BACKGROUND_ORIG}" "${PRODUCT_BACKGROUND}" +2
CopyFiles "${PRODUCT_BACKGROUND_ORIG}" "${PRODUCT_BACKGROUND}"
Delete "${PRODUCT_BACKGROUND_ORIG}"
SectionEnd

1) The destination file name gets truncated to "backgrou.jpg" (and a second time to "backgrou (2).jpg"): the base name appears to be only eight bytes long.
2) The original file is not deleted. I don't manage to delete any file in the destination directory.

What am I overlooking?
Thanks for your help!

Kristoff

Why are you using StrCmp? To see if the path exists? If so, try IfFileExists.

Also, never extra to say, try use full paths in CopyFiles.


Hey, adding the path solves all these file related issues! I corrected the code with Joel's suggestion, and after success did the same in a cleaner way by renaming instead of copying.
Now the action in the code looks like this:


StrCmp "${PRODUCT_BACKGROUND_ORIG}" "${PRODUCT_BACKGROUND}" +2
Delete "$INSTDIR\${PRODUCT_BACKGROUND}"
Rename "$INSTDIR\${PRODUCT_BACKGROUND_ORIG}" "$INSTDIR\${PRODUCT_BACKGROUND}"


The StrCmp function is used for performing the action only if the two file names differ from each other, and I delete a possible former installed target file before renaming the original file to the target file.
With this strategy I choose one file (= PRODUCT_BACKGROUND_ORIG) from an available set of files to be installed as the specified target file (= PRODUCT_BACKGROUND).

Thanks Joel!
Kristoff

No problem :)