|
From: <xue...@us...> - 2003-07-19 13:52:35
|
Update of /cvsroot/popfile/windows
In directory sc8-pr-cvs1:/tmp/cvs-serv1042
Modified Files:
pfi-library.nsh
Log Message:
Using GetFullPathName makes un.GetCorpusPath simpler and makes un.GetParent redundant. Start adopting the "MUI" coding standard.
Index: pfi-library.nsh
===================================================================
RCS file: /cvsroot/popfile/windows/pfi-library.nsh,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** pfi-library.nsh 12 Jul 2003 22:00:46 -0000 1.2
--- pfi-library.nsh 19 Jul 2003 13:52:31 -0000 1.3
***************
*** 2,7 ****
#
# pfi-library.nsi --- This is a collection of library functions and macro
! # definitions used by the NSIS script used to create the
! # Windows installer for POPFile.
#
# Copyright (c) 2001-2003 John Graham-Cumming
--- 2,7 ----
#
# pfi-library.nsi --- This is a collection of library functions and macro
! # definitions used by 'installer.nsi', the NSIS script
! # used to create the Windows installer for POPFile.
#
# Copyright (c) 2001-2003 John Graham-Cumming
***************
*** 91,95 ****
StrCmp ${L_SUBFOLDER} "no" +6
Push ${L_CORPUS}
! Push ${PATH}
Call un.StrStr
POP ${L_TEMP}
--- 91,95 ----
StrCmp ${L_SUBFOLDER} "no" +6
Push ${L_CORPUS}
! Push "${PATH}"
Call un.StrStr
POP ${L_TEMP}
***************
*** 98,102 ****
StrCmp ${L_TEMP} "" 0 +2
! RMDir /r ${PATH}
!macroend
--- 98,102 ----
StrCmp ${L_TEMP} "" 0 +2
! RMDir /r "${PATH}"
!macroend
***************
*** 143,147 ****
ClearErrors
! FileOpen ${L_CFG} $INSTDIR\popfile.cfg r
loop:
--- 143,147 ----
ClearErrors
! FileOpen ${L_CFG} "$INSTDIR\popfile.cfg" r
loop:
***************
*** 235,242 ****
StrCpy ${L_CORPUS} ""
! IfFileExists ${L_SOURCE}\popfile.cfg 0 use_default_locn
ClearErrors
! FileOpen ${L_FILE_HANDLE} ${L_SOURCE}\popfile.cfg r
loop:
--- 235,242 ----
StrCpy ${L_CORPUS} ""
! IfFileExists "${L_SOURCE}\popfile.cfg" 0 use_default_locn
ClearErrors
! FileOpen ${L_FILE_HANDLE} "${L_SOURCE}\popfile.cfg" r
loop:
***************
*** 279,330 ****
Call un.StrBackSlash ; ensure corpus path uses backslashes
Pop ${L_CORPUS}
!
! StrCpy ${L_TEMP} ${L_CORPUS} 2
! StrCmp ${L_TEMP} ".\" sub_folder
! StrCmp ${L_TEMP} "\\" got_path
!
! StrCpy ${L_TEMP} ${L_CORPUS} 3
! StrCmp ${L_TEMP} "..\" relative_folder
!
! StrCpy ${L_TEMP} ${L_CORPUS} 1
! StrCmp ${L_TEMP} "\" instdir_drive
!
! StrCpy ${L_TEMP} ${L_CORPUS} 1 1
! StrCmp ${L_TEMP} ":" got_path
!
! ; Assume path can be safely added to $INSTDIR
!
! StrCpy ${L_CORPUS} $INSTDIR\${L_CORPUS}
! Goto got_path
!
! sub_folder:
! StrCpy ${L_CORPUS} ${L_CORPUS} "" 2
! StrCpy ${L_CORPUS} $INSTDIR\${L_CORPUS}
! Goto got_path
!
! relative_folder:
! StrCpy ${L_RESULT} $INSTDIR
!
! relative_again:
! StrCpy ${L_CORPUS} ${L_CORPUS} "" 3
! Push ${L_RESULT}
! Call un.GetParent
! Pop ${L_RESULT}
! StrCpy ${L_TEMP} ${L_CORPUS} 3
! StrCmp ${L_TEMP} "..\" relative_again
! StrCpy ${L_CORPUS} ${L_RESULT}\${L_CORPUS}
! Goto got_path
!
! instdir_drive:
! StrCpy ${L_TEMP} $INSTDIR 2
! StrCpy ${L_CORPUS} ${L_TEMP}${L_CORPUS}
! Goto got_path
use_default_locn:
! StrCpy ${L_CORPUS} ${L_SOURCE}\corpus
got_path:
- StrCpy ${L_RESULT} ${L_CORPUS}
-
Pop ${L_TEMP}
Pop ${L_FILE_HANDLE}
--- 279,300 ----
Call un.StrBackSlash ; ensure corpus path uses backslashes
Pop ${L_CORPUS}
!
! StrCpy ${L_TEMP} "$OUTDIR" ; Save current working directory
!
! ; Ensure relative paths are handled properly (${L_SOURCE} holds path to 'popfile.cfg' file)
!
! StrCpy "$OUTDIR" "${L_SOURCE}"
! GetFullPathName ${L_RESULT} "${L_CORPUS}"
!
! StrCpy "$OUTDIR" ${L_TEMP} ; Restore current working directory
!
! ; If 'corpus' path parameter was not valid, GetFullPathName returns ""
!
! StrCmp ${L_RESULT} "" use_default_locn got_path
use_default_locn:
! StrCpy ${L_RESULT} "${L_SOURCE}\corpus"
got_path:
Pop ${L_TEMP}
Pop ${L_FILE_HANDLE}
***************
*** 385,432 ****
nothing_to_do:
- Pop $R2
- Pop $R1
- Exch $R0
- FunctionEnd
-
- #--------------------------------------------------------------------------
- # Function: un.GetParent
- #
- # This function is used by the uninstaller when it looks for the corpus files for the version
- # of POPFile which is being upgraded. It extracts the parent directory from a given path.
- #
- # NB: Path is assumed to use backslashes (\)
- #
- # Inputs:
- # (top of stack) - string containing a path (e.g. C:\A\B\C)
- #
- # Outputs:
- # (top of stack) - the parent part of the input string (e.g. C:\A\B)
- #
- # Usage Example:
- # Push "C:\Program Files\Directory\Whatever"
- # Call un.GetParent
- # Pop $R0
- #
- # ($R0 at this point is ""C:\Program Files\Directory")
- #
- #--------------------------------------------------------------------------
-
- Function un.GetParent
- Exch $R0
- Push $R1
- Push $R2
-
- StrCpy $R1 -1
-
- loop:
- StrCpy $R2 $R0 1 $R1
- StrCmp $R2 "" exit
- StrCmp $R2 "\" exit
- IntOp $R1 $R1 - 1
- Goto loop
-
- exit:
- StrCpy $R0 $R0 $R1
Pop $R2
Pop $R1
--- 355,358 ----
|