@@ -100,7 +100,7 @@ object WixHelper {
100
100
val pathAddition =
101
101
if (dir.isEmpty) " %" + homeEnvVar + " %"
102
102
else " [INSTALLDIR]" + dir.replaceAll(" \\ /" , " \\\\ " )
103
- val id = cleanStringForId (dir).takeRight( 65 ) + " PathC"
103
+ val id = cleanStringWithPostfix (dir, 64 , " PathC" )
104
104
val guid = makeGUID
105
105
val xml =
106
106
<DirectoryRef Id ={ dirRef }>
@@ -116,7 +116,7 @@ object WixHelper {
116
116
val dir = parentDir(uname).replaceAll(" //" , " /" ).stripSuffix(" /" ).stripSuffix(" /" )
117
117
val dirRef = if (dir.isEmpty) " INSTALLDIR" else cleanStringForId(dir)
118
118
val fname = simpleName(uname)
119
- val id = cleanStringForId (uname).takeRight( 67 ) // Room for "fl_"
119
+ val id = cleanStringWithPostfix (uname, 66 , " " ) // Room for "fl_"
120
120
val xml =
121
121
<DirectoryRef Id ={ dirRef }>
122
122
<Component Id ={ id } Guid ={ makeGUID }>
@@ -140,7 +140,7 @@ object WixHelper {
140
140
// that we remove all menu items.
141
141
case AddShortCuts (targets, workingDir) =>
142
142
val targetSize = targets.size.toString.size
143
- val id = cleanStringForId (" shortcut_" + makeGUID).takeRight( 67 - targetSize) // Room for "_SC"+incremental number
143
+ val id = cleanStringWithPostfix (" shortcut_" + makeGUID, 67 - targetSize, " " ) // Room for "_SC"+incremental number
144
144
val xml =
145
145
<DirectoryRef Id =" ApplicationProgramsFolder" >
146
146
<Component Id ={ id } Guid ={ makeGUID }>
@@ -167,7 +167,7 @@ object WixHelper {
167
167
}).toMap
168
168
169
169
val removeId =
170
- cleanStringForId (" ApplicationProgramsFolderRemove" ).takeRight( 67 )
170
+ cleanStringWithPostfix (" ApplicationProgramsFolderRemove" , 67 , " " )
171
171
<xml : group >
172
172
<!-- Define the directories we use -->
173
173
<Directory Id =' TARGETDIR' Name =' SourceDir' >
@@ -228,7 +228,7 @@ object WixHelper {
228
228
<Wix xmlns ={ namespaceDefinitions.namespace } xmlns : util ={ namespaceDefinitions.utilExtension }>
229
229
<Product Id ={ product.id } Name ={ product.title } Language =' 1033' Version ={ product.version } Manufacturer ={ product.maintainer } UpgradeCode ={ product.upgradeId }>
230
230
<Package Description ={ product.description } Comments ={ product.comments } Manufacturer ={ product.maintainer } InstallScope ={ product.installScope } InstallerVersion ={ product.installerVersion } Compressed ={ if (product.compressed) " yes" else " no" }/>
231
- <Media Id =' 1' Cabinet ={ cleanStringForId (name.toLowerCase).takeRight( 66 ) + " .cab" } EmbedCab =' yes' />
231
+ <Media Id =' 1' Cabinet ={ cleanStringWithPostfix (name.toLowerCase, 65 , " .cab" ) } EmbedCab =' yes' />
232
232
{ rest }
233
233
</Product >
234
234
</Wix >
@@ -256,8 +256,17 @@ object WixHelper {
256
256
* characters and replacing with _. Also limits the width to 70 (rather than
257
257
* 72) so we can safely add a few later.
258
258
*/
259
- def cleanStringForId (n : String ) =
260
- n.replaceAll(" [^0-9a-zA-Z_]" , " _" ).takeRight(60 ) + (math.abs(n.hashCode).toString + " xxxxxxxxx" ).substring(0 , 9 )
259
+ def cleanStringForId (n : String ) = {
260
+ val x = n.replaceAll(" [^0-9a-zA-Z_]" , " _" ).takeRight(59 ) + (math.abs(n.hashCode).toString + " xxxxxxxxx" ).substring(0 , 9 )
261
+ if (x startsWith " _" ) x
262
+ else " _" + x
263
+ }
264
+
265
+ def cleanStringWithPostfix (n : String , num : Int , postfix : String ): String = {
266
+ val x = cleanStringForId(n).takeRight(num) + postfix
267
+ if (x startsWith " _" ) x
268
+ else " _" + x
269
+ }
261
270
262
271
/** Cleans a file name for the Wix pre-processor. Every $ should be doubled. */
263
272
def cleanFileName (n : String ) =
0 commit comments