diff --git a/Docs/src/headers.but b/Docs/src/headers.but
index 351c9d75..62c0fbd6 100644
--- a/Docs/src/headers.but
+++ b/Docs/src/headers.but
@@ -65,7 +65,7 @@ Call functions:
\c ; /B=0 - Banner isn't used (default)
\c ; /B=1 - Banner is used. Callback when function
\c ; start to search in new directory
-\c "Function" ; Callback function then found
+\c "Function" ; Callback function when found
\c
\c Function "Function"
\c ; $R9 "path\name"
@@ -420,7 +420,7 @@ Call functions:
\c ; [ALL]
\c ; Find all drives by letter (default)
\c ;
-\c "Function" ; Callback function then found
+\c "Function" ; Callback function when found
\c
\c Function "Function"
\c ; $9 "drive letter" (a:\ c:\ ...)
@@ -611,7 +611,7 @@ Call functions:
\S1{} GetExeName
-\b Get installer filename (also valid case for Windows 9X).
+\b Get installer filename (with valid case for Windows 9X/Me).
\\Syntax:\\
@@ -626,7 +626,7 @@ Call functions:
\S1{} GetExePath
-\b Get installer pathname ($EXEDIR with valid case for Windows 9X).
+\b Get installer pathname ($EXEDIR with valid case for Windows 9X/Me).
\\Syntax:\\
@@ -792,18 +792,20 @@ Call functions:
\c "[PathString]" ;
\c ;
-\c "[Option]" ; [Lenght][A|B|C]
+\c "[Option]" ; [Length][A|B|C|D]
\c ;
-\c ; Lenght -Maximum string lenght
+\c ; Length -Maximum string length
\c ; A -Trim center path (default)
\c ; (C:\root\...\third path)
\c ; If A mode not possible Then will be used B mode
-\c ; If B mode not possible Then will be used C mode
\c ; B -Trim right path
\c ; (C:\root\second path\...)
\c ; If B mode not possible Then will be used C mode
\c ; C -Trim right string
\c ; (C:\root\second path\third p...)
+\c ; D -Trim right string + filename
+\c ; (C:\root\second p...\third path)
+\c ; If D mode not possible Then will be used C mode
\c ;
\c $var ; Result: Trimmed path
diff --git a/Examples/FileFunc.nsi b/Examples/FileFunc.nsi
index 28002a4a..97b37001 100644
--- a/Examples/FileFunc.nsi
+++ b/Examples/FileFunc.nsi
@@ -100,7 +100,7 @@ Function ShowCustom
StrCpy $GETBASENAME1 'C:\path\file.dll'
StrCpy $GETFILEEXT1 'C:\path\file.dll'
StrCpy $BANNERTRIMPATH1 'C:\Server\Documents\Terminal\license.htm'
- StrCpy $BANNERTRIMPATH2 '35A'
+ StrCpy $BANNERTRIMPATH2 '34A'
StrCpy $DIRSTATE1 '$TEMP'
GetDlgItem $1 $HWND 1203
diff --git a/Examples/FileFuncTest.nsi b/Examples/FileFuncTest.nsi
index 683a7c3e..ca1da81e 100644
--- a/Examples/FileFuncTest.nsi
+++ b/Examples/FileFuncTest.nsi
@@ -451,6 +451,18 @@ Section BannerTrimPath
${BannerTrimPath} 'C:\12\3456\789' '11C' $OUT1
StrCmp $OUT1 'C:\12\34...' 0 error
+ ${BannerTrimPath} 'C:\12\3456\789' '9D' $OUT1
+ StrCmp $OUT1 'C:\12\...' 0 error
+
+ ${BannerTrimPath} 'C:\12\3456\789' '10D' $OUT1
+ StrCmp $OUT1 'C:\...\789' 0 error
+
+ ${BannerTrimPath} 'C:\12\3456\789' '11D' $OUT1
+ StrCmp $OUT1 'C:\1...\789' 0 error
+
+ ${BannerTrimPath} '123456789' '5D' $OUT1
+ StrCmp $OUT1 '12...' 0 error
+
goto +2
error:
SetErrors
diff --git a/Include/FileFunc.nsh b/Include/FileFunc.nsh
index 138ca976..b4537295 100644
--- a/Include/FileFunc.nsh
+++ b/Include/FileFunc.nsh
@@ -1,7 +1,7 @@
/*
_____________________________________________________________________________
- File Functions Header v2.5
+ File Functions Header v2.6
_____________________________________________________________________________
2005 Shengalts Aleksander aka Instructor (Shengalts@mail.ru)
@@ -1063,34 +1063,41 @@ RefreshShellIcons
Push $4
Push $5
Push $6
+ Push $7
ClearErrors
StrCmp $1 'L' gettime
- System::Call '*(i,l,l,l,i,i,i,i,&t260,&t14) i .r2'
- System::Call 'kernel32::FindFirstFileA(t,i)i(r0,r2) .r3'
- IntCmp $3 -1 error
- System::Call 'kernel32::FindClose(i)i(r3)'
+ StrCmp $1 'A' getfile
+ StrCmp $1 'C' getfile
+ StrCmp $1 'M' getfile
+ goto error
+
+ getfile:
+ IfFileExists $0 0 error
+ System::Call '*(i,l,l,l,i,i,i,i,&t260,&t14) i .r6'
+ System::Call 'kernel32::FindFirstFileA(t,i)i(r0,r6) .r2'
+ System::Call 'kernel32::FindClose(i)i(r2)'
gettime:
- System::Call '*(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2) i .r0'
+ System::Call '*(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2) i .r7'
StrCmp $1 'L' 0 filetime
- System::Call 'kernel32::GetLocalTime(i)i(r0)'
+ System::Call 'kernel32::GetLocalTime(i)i(r7)'
goto convert
filetime:
- System::Call '*$2(i,l,l,l,i,i,i,i,&t260,&t14)i(,.r6,.r5,.r4)'
+ System::Call '*$6(i,l,l,l,i,i,i,i,&t260,&t14)i(,.r4,.r3,.r2)'
+ System::Free $6
StrCmp $1 'A' 0 +3
- StrCpy $4 $5
- goto +5
- StrCmp $1 'C' 0 +3
- StrCpy $4 $6
- goto +2
- StrCmp $1 'M' 0 error
- System::Call 'kernel32::FileTimeToLocalFileTime(*l,*l)i(r4,.r3)'
- System::Call 'kernel32::FileTimeToSystemTime(*l,i)i(r3,r0)'
+ StrCpy $2 $3
+ goto +3
+ StrCmp $1 'C' 0 +2
+ StrCpy $2 $4
+ System::Call 'kernel32::FileTimeToLocalFileTime(*l,*l)i(r2,.r3)'
+ System::Call 'kernel32::FileTimeToSystemTime(*l,i)i(r3,r7)'
convert:
- System::Call '*$0(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2)i(.r5,.r6,.r4,.r0,.r3,.r2,.r1,)'
+ System::Call '*$7(&i2,&i2,&i2,&i2,&i2,&i2,&i2,&i2)i(.r5,.r6,.r4,.r0,.r3,.r2,.r1,)'
+ System::Free $7
IntCmp $0 9 0 0 +2
StrCpy $0 '0$0'
@@ -1134,6 +1141,7 @@ RefreshShellIcons
StrCpy $6 ''
end:
+ Pop $7
Exch $6
Exch
Exch $5
@@ -1357,23 +1365,8 @@ RefreshShellIcons
Function ${_FILEFUNC_UN}GetExeName
Push $0
- Push $1
-
- StrCpy $1 $CMDLINE 1
- StrCmp $1 '"' 0 kernel
- StrCpy $1 0
- IntOp $1 $1 + 1
- StrCpy $0 $CMDLINE 1 $1
- StrCmp $0 '"' 0 -2
- IntOp $1 $1 - 1
- StrCpy $0 $CMDLINE $1 1
- goto end
-
- kernel:
- System::Call 'kernel32::GetModuleFileNameA(i 0, t .r0, i 1024) i r1'
-
- end:
- Pop $1
+ System::Call 'kernel32::GetModuleFileNameA(i 0, t .r0, i 1024)'
+ System::Call 'kernel32::GetLongPathNameA(t r0, t .r0, i 1024)'
Exch $0
FunctionEnd
@@ -1391,31 +1384,8 @@ RefreshShellIcons
Function ${_FILEFUNC_UN}GetExePath
Push $0
- Push $1
- Push $2
-
- StrCpy $1 $CMDLINE 1
- StrCmp $1 '"' 0 exedir
- StrCpy $1 0
- IntOp $1 $1 + 1
- StrCpy $0 $CMDLINE 1 $1
- StrCmp $0 '"' 0 -2
- IntOp $1 $1 - 1
- StrCpy $0 $CMDLINE $1 1
-
- StrCpy $1 0
- IntOp $1 $1 - 1
- StrCpy $2 $0 1 $1
- StrCmp $2 '\' 0 -2
- StrCpy $0 $0 $1
- goto end
-
- exedir:
StrCpy $0 $EXEDIR
-
- end:
- Pop $2
- Pop $1
+ System::Call 'kernel32::GetLongPathNameA(t r0, t .r0, i 1024)'
Exch $0
FunctionEnd
@@ -1814,6 +1784,7 @@ RefreshShellIcons
StrCmp $3 'A' A-trim
StrCmp $3 'B' B-trim
StrCmp $3 'C' C-trim
+ StrCmp $3 'D' D-trim
A-trim:
StrCpy $3 $0 1 1
@@ -1854,6 +1825,19 @@ RefreshShellIcons
StrCpy $0 '$0...'
goto end
+ D-trim:
+ StrCpy $3 -1
+ IntOp $3 $3 - 1
+ StrCmp $3 -$2 C-trim
+ StrCpy $4 $0 1 $3
+ StrCmp $4 '\' 0 -3
+ StrCpy $4 $0 '' $3
+ IntOp $3 $1 + $3
+ IntCmp $3 2 C-trim C-trim
+ StrCpy $0 $0 $3
+ StrCpy $0 '$0...$4'
+ goto end
+
empty:
StrCpy $0 ''