' Распаковка языкового PAK-файла Chromium ' Параметр командной строки - имя упакованного файла. ' Если параметр отсутствует, то по умолчанию ru.pak ' Распаковывает в файл с расширением unp Option Explicit Dim fso, f1, f2, s, ch, path, filename, i, j, iCount, rc, currpos, nextpos Select Case WScript.Arguments.Count Case 0: filename = "ru.pak" Case 1: filename = WScript.Arguments.Item(0) Case Else MsgBox "Недопустимое количество параметров командной строки!" WScript.Quit End Select Dim A() Set fso = CreateObject("Scripting.FileSystemObject") path = "" Set f1 = fso.OpenTextFile(path + filename,1, False, 0) Set f2 = fso.OpenTextFile(path + Left(filename, InStr(1,filename, ".")) + "unp",2,True) iCount = fso.GetFile(path + filename).Size - 1 ReDim A(iCount) For i = 0 To iCount s = f1.Read(1) A(i) = Asc(s) next 'rc = Read4(4) rc = A(8) + A(9) * 256 currpos = 12 nextpos = currpos + 6 f2.WriteLine "[Info]" f2.WriteLine "Version=" + CStr(A(0)) f2.WriteLine "RowCount=" + CStr(rc) f2.WriteLine "Build.Win=" ' Сюда можно вписать версию сборки браузера f2.WriteLine "" f2.WriteLine "[Translation]" For i = 1 To rc s = "" For j = read4(currpos +2) To read4(nextpos +2) - 1 ch = A(j) Select Case ch Case 13: s = s + Chr(8) Case 10: s = s + Chr(7) Case else s = s + Chr(A(j)) End select next f2.WriteLine CStr(A(currpos) + A(currpos + 1) * 256) + "=""" + s + """" currpos = nextpos nextpos = currpos + 6 Next f1.Close f2.Close WScript.Echo "OK" Function Read4(offset)' Возвращает 4-байтовое число Dim n n = A(offset) + A(offset + 1) * 256 + A(offset + 2) * 256 * 256 + A(offset + 3) * 256 * 256 * 256 Read4 = n End Function |