From 376dc75b2d684426d599f966c30a88c9d5d3651f Mon Sep 17 00:00:00 2001 From: mbirth Date: Fri, 13 Apr 2007 12:35:44 +0000 Subject: [PATCH] x removed several variables from replacement queue because replacing any "1.0" by "U3_ENV_VERSION" doesn't make any sense ! found U3_ENV_SUB_VERSION + added ParseIniFiles-section to parse .ini-files and replace envvars --- U3H_hostCleanUp.ahk | 33 +++++++++++++++++++++++++++++ U3H_hostConfigure.ahk | 32 ++++++++++++++++++++++++++++ U3Helper.ahk | 5 ++++- U3Helperex.ini | 6 ++++++ mb_EnvTools.ahk | 6 ++---- mb_EnvTools.txt | 49 ++++++++++++++++++++++--------------------- 6 files changed, 102 insertions(+), 29 deletions(-) diff --git a/U3H_hostCleanUp.ahk b/U3H_hostCleanUp.ahk index 0fcf91a..5d4a25c 100644 --- a/U3H_hostCleanUp.ahk +++ b/U3H_hostCleanUp.ahk @@ -9,6 +9,8 @@ If (StrLen(RunBeforeEject) > 0) StepsAll++ If regsvr0 > 0 StepsAll++ +If datini0 > 0 + StepsAll++ If datexe0 > 0 StepsAll++ If regbak0 > 0 @@ -154,6 +156,37 @@ Else If datexe0 > 0 StepsPos++ + + ;Translate paths in INI files + Loop %datini0% + { + Progress % StepsPos*StepsStep+StepsStep*(A_Index-1)/datini0, Translating paths in file %CurFile% ... + CurFile := datini%A_Index% + TmpFile := "$$$" . CurFile + FileMove %U3_APP_DATA_PATH%\%CurFile%, %U3_APP_DATA_PATH%\%TmpFile%, 1 + Progress % StepsPos*StepsStep+StepsStep*(A_Index-0.5)/datini0, Translating paths in file %CurFile% ... + Loop Read, %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile% + { + IfNotInString A_LoopReadLine, = + { + ; no key/value-pair --- skip processing + FileAppend %A_LoopReadLine%`n + Continue + } + IfNotInString A_LoopReadLine, \ + { + ; no paths to replace --- skip processing + FileAppend %A_LoopReadLine%`n + Continue + } + SplitFirst(IKey, IVal, A_LoopReadLine, "=") + FileAppend % IKey . "=" . EnvUnparseStr(IVal) . "`n" + } + FileDelete %U3_APP_DATA_PATH%\%TmpFile% + } + + If datini0 > 0 + StepsPos++ } IniRead KeepSettings, %INIFile%, U3Helper, KeepSettings, 0 diff --git a/U3H_hostConfigure.ahk b/U3H_hostConfigure.ahk index c93fa27..8fa4e03 100644 --- a/U3H_hostConfigure.ahk +++ b/U3H_hostConfigure.ahk @@ -7,6 +7,8 @@ StepsAll = 0 If regsvr0 > 0 StepsAll++ +If datini0 > 0 + StepsAll++ If datexe0 > 0 StepsAll++ If regbak0 > 0 @@ -94,6 +96,36 @@ If (ForeignSettings = "0") StepsPos++ } +;Translate paths in INI files +Loop %datini0% +{ + Progress % StepsPos*StepsStep+StepsStep*(A_Index-1)/datini0, Translating paths in file %CurFile% ... + CurFile := datini%A_Index% + TmpFile := "$$$" . CurFile + FileMove %U3_APP_DATA_PATH%\%CurFile%, %U3_APP_DATA_PATH%\%TmpFile%, 1 + Progress % StepsPos*StepsStep+StepsStep*(A_Index-0.5)/datini0, Translating paths in file %CurFile% ... + Loop Read, %U3_APP_DATA_PATH%\%TmpFile%, %U3_APP_DATA_PATH%\%CurFile% + { + IfNotInString A_LoopReadLine, = + { + ; no key/value-pair --- skip processing + FileAppend %A_LoopReadLine%`n + Continue + } + IfNotInString A_LoopReadLine, `% + { + ; no envvars to replace --- skip processing + FileAppend %A_LoopReadLine%`n + Continue + } + SplitFirst(IKey, IVal, A_LoopReadLine, "=") + FileAppend % IKey . "=" . EnvParseStr(IVal) . "`n" + } + FileDelete %U3_APP_DATA_PATH%\%TmpFile% +} + +If datini0 > 0 + StepsPos++ ;Copy data files Loop %datexe0% diff --git a/U3Helper.ahk b/U3Helper.ahk index 34b8539..c555125 100644 --- a/U3Helper.ahk +++ b/U3Helper.ahk @@ -3,7 +3,7 @@ #Include mb_EnvTools.ahk #Include mb_IniTools.ahk #Include mb_TextTools.ahk -U3HVer = 1.7 +U3HVer = 1.8 SplitPath A_ScriptFullPath, null, ScrDir, null, ScrFile, ScrDrive INIFile = %ScrDir%\%ScrFile%.ini @@ -14,6 +14,7 @@ IniRead RunBeforeStop, %INIFile%, U3Helper, RunBeforeStop, %A_Space% IniRead RunBeforeEject, %INIFile%, U3Helper, RunBeforeEject, %A_Space% IniGetKeys("regsvr", INIFile, "regsvr32") IniGetKeys("datexe", INIFile, "DataToExecDir") +IniGetKeys("datini", INIFile, "ParseIniFiles") IniGetKeys("regbak", INIFile, "RegBackup") IniGetKeys("regdel", INIFile, "RegDelete") IniGetKeys("fildel", INIFile, "FileDelete") @@ -21,6 +22,8 @@ IniGetKeys("fildel", INIFile, "FileDelete") U3_APP_DATA_PATH := EnvValue("U3_APP_DATA_PATH") U3_HOST_EXEC_PATH := EnvValue("U3_HOST_EXEC_PATH") U3_DEVICE_EXEC_PATH := EnvValue("U3_DEVICE_EXEC_PATH") +EnvGet U3_IS_DEVICE_AVAILABLE, U3_IS_DEVICE_AVAILABLE +EnvGet U3_IS_AUTORUN, U3_IS_AUTORUN WinGetPos,Tx,Ty,Tw,Th,ahk_class Shell_TrayWnd,,, ; Tw>Th: horizontal taskbar (top or bottom) diff --git a/U3Helperex.ini b/U3Helperex.ini index 7239c8a..1be98b6 100644 --- a/U3Helperex.ini +++ b/U3Helperex.ini @@ -33,6 +33,12 @@ CCListBar.ocx safe.dat safe.ind +[ParseIniFiles] +; enter filenames of .ini-files to be parsed for env vars on hostConfigure +; and re-replace the paths by envvars on hostCleanUp. The files should reside +; in %U3_APP_DATA_PATH% +test.ini + [FileDelete] ; enter filenames or foldernames to be deleted on eject ; Environment variables working (case sensitive!): diff --git a/mb_EnvTools.ahk b/mb_EnvTools.ahk index e020c52..94685da 100644 --- a/mb_EnvTools.ahk +++ b/mb_EnvTools.ahk @@ -4,10 +4,8 @@ EnvVars0 = 0 EnvVals0 = 0 ; initial list of EnvVars to load -EnvVarsAll := "U3_DEVICE_SERIAL,U3_DEVICE_PATH,U3_DEVICE_DOCUMENT_PATH,U3_DEVICE_VENDOR,U3_DEVICE_PRODUCT,U3_DEVICE_VENDOR_ID" -EnvVarsAll .= ",U3_APP_DATA_PATH,U3_HOST_EXEC_PATH,U3_DEVICE_EXEC_PATH,U3_ENV_VERSION,U3_ENV_LANGUAGE,U3_IS_UPGRADE" -EnvVarsAll .= ",U3_IS_DEVICE_AVAILABLE,U3_IS_AUTORUN,U3_DAPI_CONNECT_STRING" -EnvVarsAll .= ",ALLUSERSPROFILE,APPDATA,CommonProgramFiles,HOMEPATH,ProgramFiles,SystemRoot,USERPROFILE,TEMP,windir" +EnvVarsAll := "U3_DEVICE_PATH,U3_DEVICE_DOCUMENT_PATH,U3_DEVICE_VENDOR,U3_DEVICE_PRODUCT,U3_APP_DATA_PATH,U3_HOST_EXEC_PATH" +EnvVarsAll .= ",U3_DEVICE_EXEC_PATH,ALLUSERSPROFILE,APPDATA,CommonProgramFiles,HOMEPATH,ProgramFiles,SystemRoot,USERPROFILE,TEMP,windir" StringSplit EnvVarsx, EnvVarsAll, `,%A_Space% diff --git a/mb_EnvTools.txt b/mb_EnvTools.txt index 5517e5a..7c1b971 100644 --- a/mb_EnvTools.txt +++ b/mb_EnvTools.txt @@ -1,24 +1,25 @@ -EnvAdd("U3_DEVICE_SERIAL") ; serial number of device (copy protection) -EnvAdd("U3_DEVICE_PATH") ; drive letter to device (F:) -EnvAdd("U3_DEVICE_DOCUMENT_PATH") ; path to documents (F:\Documents) -EnvAdd("U3_DEVICE_VENDOR") ; vendor -EnvAdd("U3_DEVICE_PRODUCT") ; product name string -EnvAdd("U3_DEVICE_VENDOR_ID") ; vendor id (decimal!! 2284 = 0x08ec) -EnvAdd("U3_APP_DATA_PATH") ; data path for app (on device) -EnvAdd("U3_HOST_EXEC_PATH") ; path to exe on host -EnvAdd("U3_DEVICE_EXEC_PATH") ; path to needed files on device -EnvAdd("U3_ENV_VERSION") ; should be 1.0 -EnvAdd("U3_ENV_LANGUAGE") ; language id of LaunchPad -EnvAdd("U3_IS_UPGRADE") ; can be "false" or "true" -EnvAdd("U3_IS_DEVICE_AVAILABLE") ; "true"/"false" -EnvAdd("U3_IS_AUTORUN") ; is this an autorun-launch? "true"/"false" -EnvAdd("U3_DAPI_CONNECT_STRING") ; who needs this? -EnvAdd("ALLUSERSPROFILE") ; C:\Documents and Settings\All Users -EnvAdd("APPDATA") ; C:\Doc...\\Application Data -EnvAdd("CommonProgramFiles") ; C:\Program Files\Common Files -EnvAdd("HOMEPATH") ; C:\Documents and Settings\ -EnvAdd("ProgramFiles") ; C:\Program Files -EnvAdd("SystemRoot") ; C:\WINDOWS -EnvAdd("USERPROFILE") ; C:\Documents and Settings\ -EnvAdd("TEMP") ; C:\DOCUME~1\\LOCALS~1\Temp -EnvAdd("windir") ; C:\WINDOWS +U3_DEVICE_SERIAL serial number of device (copy protection, e.g. 0000060415134347) +U3_DEVICE_PATH drive letter to device (F:) +U3_DEVICE_DOCUMENT_PATH path to documents (F:\Documents) +U3_DEVICE_VENDOR vendor +U3_DEVICE_PRODUCT product name string +U3_DEVICE_VENDOR_ID vendor id (decimal!! 2284 = 0x08ec) +U3_APP_DATA_PATH data path for app (on device: X:\System\Apps\{GUID}\Data) +U3_HOST_EXEC_PATH path to exe on host (%AppData%\U3\%U3_DEVICE_SERIAL%\{GUID}\Exec) +U3_DEVICE_EXEC_PATH path to needed files on device (X:\System\Apps\{GUID}\Exec) +U3_ENV_VERSION should be 1.0 +U3_ENV_SUB_VERSION ??? (currently 2) +U3_ENV_LANGUAGE language id of LaunchPad (1033=English, 1031=German, etc.) +U3_IS_UPGRADE can be "false" or "true" +U3_IS_DEVICE_AVAILABLE "true"/"false" +U3_IS_AUTORUN is this an autorun-launch? "true"/"false" +U3_DAPI_CONNECT_STRING who needs this? (=U3_DEVICE_SERIAL ???) +ALLUSERSPROFILE C:\Documents and Settings\All Users +APPDATA C:\Doc...\\Application Data +CommonProgramFiles C:\Program Files\Common Files +HOMEPATH C:\Documents and Settings\ +ProgramFiles C:\Program Files +SystemRoot C:\WINDOWS +USERPROFILE C:\Documents and Settings\ +TEMP C:\DOCUME~1\\LOCALS~1\Temp +windir C:\WINDOWS