OSDN Git Service

PATCH: [ 1872453 ] Create POT file only if necessary
authorTim Gerundt <tim@gerundt.de>
Wed, 16 Jan 2008 21:45:11 +0000 (21:45 +0000)
committerTim Gerundt <tim@gerundt.de>
Wed, 16 Jan 2008 21:45:11 +0000 (21:45 +0000)
Src/Languages/CreateMasterPotFile.vbs

index 0e9d50e..2a7de9f 100644 (file)
@@ -33,18 +33,31 @@ Call Main
 Sub Main
   Dim oStrings, sCodePage
   Dim StartTime, EndTime, Seconds
+  Dim bNecessary
   
   StartTime = Time
   
   InfoBox "Creating POT file from Merge.rc...", 3
   
-  Set oStrings = GetStringsFromRcFile("../Merge.rc", sCodePage)
-  CreateMasterPotFile "English.pot", oStrings, sCodePage
-  
-  EndTime = Time
-  Seconds = DateDiff("s", StartTime, EndTime)
+  bNecessary = True
+  If (oFSO.FileExists("English.pot") = True) And (oFSO.FileExists("MergeLang.rc") = True) Then 'If the POT and RC file exists...
+    bNecessary = GetArchiveBit("../Merge.rc") Or GetArchiveBit("English.pot") Or GetArchiveBit("MergeLang.rc") 'RCs or POT file changed?
+  End If
   
-  InfoBox "POT file created, after " & Seconds & " second(s).", 10
+  If (bNecessary = True) Then 'If update necessary...
+    Set oStrings = GetStringsFromRcFile("../Merge.rc", sCodePage)
+    CreateMasterPotFile "English.pot", oStrings, sCodePage
+    SetArchiveBit "../Merge.rc", False
+    SetArchiveBit "English.pot", False
+    SetArchiveBit "MergeLang.rc", False
+    
+    EndTime = Time
+    Seconds = DateDiff("s", StartTime, EndTime)
+    
+    InfoBox "POT file created, after " & Seconds & " second(s).", 10
+  Else 'If update NOT necessary...
+    InfoBox "POT file already up-to-date.", 10
+  End If
 End Sub
 
 ''
@@ -315,3 +328,36 @@ Function InfoBox(ByVal sText, ByVal iSecondsToWait)
     Wscript.Echo sText
   End If
 End Function
+
+''
+' ...
+Function GetArchiveBit(ByVal sFilePath)
+  Dim oFile
+  
+  GetArchiveBit = False
+  If (oFSO.FileExists(sFilePath) = True) Then 'If the file exists...
+    Set oFile = oFSO.GetFile(sFilePath)
+    If (oFile.Attributes AND 32) Then 'If archive bit set...
+      GetArchiveBit = True
+    End If
+  End If
+End Function
+
+''
+' ...
+Sub SetArchiveBit(ByVal sFilePath, ByVal bValue)
+  Dim oFile
+  
+  If (oFSO.FileExists(sFilePath) = True) Then 'If the file exists...
+    Set oFile = oFSO.GetFile(sFilePath)
+    If (oFile.Attributes AND 32) Then 'If archive bit set...
+      If (bValue = False) Then
+        oFile.Attributes = oFile.Attributes XOR 32
+      End If
+    Else 'If archive bit NOT set...
+      If (bValue = True) Then
+        oFile.Attributes = oFile.Attributes AND 32
+      End If
+    End If
+  End If
+End Sub