"%GCOMP_PATH%\gcomp" -c -D .\REPO -F 1cv7.compile.md>.compile.log
where REPO is the source directory in the database directory ### getSVNRevision= Return "$WCREV$"; getSVNURL= Return "$WCURL$"; getSVNBuildTime= Return "$WCNOW$";
#include "file.au3" ;$CmdLine[0] - . if $CmdLine[0] <2 Then MsgBox(0,"error!","Replacer have not all params!") Exit EndIf ; Global $SettingsFilePath = $CmdLine[1] Global $WorkFilePath = $CmdLine[2] ; if FileExists ( $SettingsFilePath) = 0 Then MsgBox(0, "Error", "Settings File is not exist!.") exit EndIf ; if FileExists ( $WorkFilePath ) = 0 Then MsgBox(0, "Error", "Global Module File is not exist!.") exit EndIf ; Local $Settingsfile = openFile($SettingsfilePath, 0) Local $T = FileRead($SettingsFilePath,3) if $T <> "###" Then MsgBox(0,"Error in the settings file!","Settings file not have in first line a secure code ###") Exit EndIf ; While 1 ; Local $line = FileReadLine($Settingsfile) ; , If @error = -1 Then ExitLoop ; Local $SeparatorPos = StringInStr($line, "=") if $SeparatorPos = 0 Then ; - ContinueLoop EndIf ; Local $find = getFindString($line) ; Local $replace = getReplaceString($line) ; ___ReplaceStringInFile($WorkFilePath,$find,$replace) WEnd FileClose($Settingsfile) ; . exit ; "file.au3" , . ; , , , . Func ___ReplaceStringInFile($szFileName, $szSearchString, $szReplaceString, $fCaseness = 0, $fOccurance = 1) Local $iRetVal = 0 Local $nCount, $sEndsWith ; Check if file is readonly .. If StringInStr(FileGetAttrib($szFileName), "R") Then Return SetError(6, 0, -1) ;=============================================================================== ;== Read the file into an array ;=============================================================================== Local $hFile = FileOpen($szFileName, $FO_READ) If $hFile = -1 Then Return SetError(1, 0, -1) Local $s_TotFile = FileRead($hFile, FileGetSize($szFileName)) If StringRight($s_TotFile, 2) = @CRLF Then $sEndsWith = @CRLF ElseIf StringRight($s_TotFile, 1) = @CR Then $sEndsWith = @CR ElseIf StringRight($s_TotFile, 1) = @LF Then $sEndsWith = @LF Else $sEndsWith = "" EndIf Local $aFileLines = StringSplit(StringStripCR($s_TotFile), @LF) FileClose($hFile) ;=============================================================================== ;== Open the output file in write mode ;=============================================================================== Local $iEncoding = FileGetEncoding($szFileName) Local $hWriteHandle = FileOpen($szFileName, $iEncoding + $FO_OVERWRITE) If $hWriteHandle = -1 Then Return SetError(2, 0, -1) ;=============================================================================== ;== Loop through the array and search for $szSearchString ;=============================================================================== local $needReplace = 0 For $nCount = 1 To $aFileLines[0] ; if $needReplace = 1 Then ; $aFileLines[$nCount] = $szReplaceString ExitLoop EndIf ; If StringInStr($aFileLines[$nCount], $szSearchString, $fCaseness) Then ; ;$aFileLines[$nCount] = StringReplace($aFileLines[$nCount], $szSearchString, $szReplaceString, 1 - $fOccurance, $fCaseness) ;"" needReplace . . $needReplace = 1 $iRetVal = $iRetVal + 1 ;====================================================================== ;== If we want just the first string replaced, copy the rest of the lines ;== and stop ;====================================================================== If $fOccurance = 0 Then $iRetVal = 1 ExitLoop EndIf EndIf Next ;=============================================================================== ;== Write the lines back to original file. ;=============================================================================== For $nCount = 1 To $aFileLines[0] - 1 If FileWriteLine($hWriteHandle, $aFileLines[$nCount]) = 0 Then FileClose($hWriteHandle) Return SetError(3, 0, -1) EndIf Next ; Write the last record and ensure it ends with the same as the input file If $aFileLines[$nCount] <> "" Then FileWrite($hWriteHandle, $aFileLines[$nCount] & $sEndsWith) FileClose($hWriteHandle) Return $iRetVal EndFunc ; Func openFile($FilePath,$mode) Local $file = FileOpen($FilePath, $mode) If $file = -1 Then MsgBox(0, "Error", "Unable to open file." $FilePath) exit Else Return $file EndIf EndFunc ; , , Func getFindString($inString) Return StringLeft($inString, StringInStr($inString, "=")-1) EndFunc ; , Func getReplaceString($inString) Return StringRight($inString, StringLen($inString)- StringInStr($inString, "=")) EndFunc
REM if not exist .\REPO ( echo FAIL: REPO folder isn't exist! pause exit /b 1 ) REM -. if not exist "%~dp0\shablon.txt" ( echo FAIL: Shablon isn't exist! pause exit /b 2 ) REM SubWCRev.exe, "c:\Program Files\TortoiseSVN\bin\SubWCRev.exe" .\REPO "%~dp0\shablon.txt" .\ReplacerSettings.txt -f REM , "%~dp0\Replacer.exe" ".\ReplacerSettings.txt" "%1\.1s" REM del ".\ReplacerSettings.txt"
@echo SVN ... @echo off call getrevision.bat .\REPO @echo REPO 1cv7.compile.md... "%GCOMP_PATH%\gcomp" -c -D .\REPO -F 1cv7.compile.md>.compile.log
Compile.bat remained unchanged //------------------------------------------------- getSVNRevision() 0; //------------------------------------------------- getSVNURL() 0; //------------------------------------------------- getSVNBuildTime() 0; //-------------------------------------------------
//------------------------------------------------- getSVNRevision() Return "5135"; //------------------------------------------------- getSVNURL() Return "https://:/svn/trunk"; //------------------------------------------------- getSVNBuildTime() Return "2013/01/22 10:35:15"; //-------------------------------------------------
MD_INFO() = ""; .( () + "1CV7.MD", , , , , , ); ; = ( "" ); .( "###MD Info" ); .( "SVN_Revision: " + getSVNRevision() ); .( "SVN_URL: " + getSVNURL() ); .( "SVN_BuildTime: " + ( getSVNBuildTime(), "/", "." ) ); .( "MD_UpdateTime: " + ); .( "### : " ); .( ": " + ( . ) ); .( ": " + ( . ) ); .( _() + "\" + ( "MDInfo", "" ) ); ;
### MD Info SVN_Revision: 5137 SVN_URL: https://:/svn/branches/_ SVN_BuildTime: 2013.01.21 13:45:44 MD_UpdateTime: 2013.01.22 05:02:52 ### : : _ : 24
Source: https://habr.com/ru/post/166769/
All Articles