|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?xml version="1.0" encoding="windows-1251"?>
- <job>
- <runtime>
- <named name="target" helpstring="Ïóòü ê ïàïêå, â êîòîðîé áóäóò ñîçäàâàòüñÿ *.zmp" required="true" type="string"/>
- <example>Example: cscript BuildZMmp.wsf /target:"..\Maps"</example>
- </runtime>
- <script language="JScript">
- <![CDATA[
- function CBuildSource(Folder, Ext){
- this.Ext = Ext;
- this.fso = WScript.CreateObject("Scripting.FileSystemObject");
- this.Folder = this.fso.GetFolder(Folder);
-
- this.SourceCheckExtRegExp = new RegExp("^" + this.Ext + "$", "i");
-
- this.CheckExt = function(Folder){
- return this.fso.GetExtensionName(Folder.Name).match(this.SourceCheckExtRegExp);
- };
-
- this.GetSourceFoldersEnumerator = function(){
- return new Enumerator(this.Folder.SubFolders);
- };
- };
-
- function CBuilder(FolderName){
- this.fso = WScript.CreateObject("Scripting.FileSystemObject");
- this.WshShell = WScript.CreateObject("WScript.Shell");
- this.FolderExists = false;
-
- this.FolderName = FolderName;
- if (FolderName.length == 0){
- this.FolderName = ".";
- };
-
- this.GetNewFullFileName = function(FileName){
- if (!this.FolderExists){
- if (!this.fso.FolderExists(this.FolderName)){
- this.Folder = this.fso.CreateFolder(FolderName);
- this.FolderExists = true;
- }else{
- this.Folder = this.fso.GetFolder(this.FolderName);
- this.FolderExists = true;
- };
- };
- return this.fso.BuildPath(this.Folder.Path, this.fso.GetFileName(FileName));
- };
- this.GetCommandLine = function(SourceFolder, FileName){
- return "7za a -tzip \""+ FileName + "\" \"" + SourceFolder + "\\*.*\"" ;
- };
- this.ProcessFolder = function(Folder){
- var NewFileName = this.GetNewFullFileName(Folder.Name);
- var FolderFullName = Folder.Path;
- if (this.fso.FileExists(NewFileName)){
- this.fso.DeleteFile(NewFileName);
- };
- var CommandLine = this.GetCommandLine(FolderFullName, NewFileName);
- WScript.Echo(CommandLine);
- var Pipe = this.WshShell.Exec(CommandLine);
- while(!Pipe.StdOut.AtEndOfStream){
- WScript.StdOut.WriteLine(Pipe.StdOut.ReadLine());
- };
- }
- };
-
- if (!WScript.Arguments.Named.Exists("target")){
- WScript.Arguments.ShowUsage();
- }else{
- var Source = new CBuildSource(".", "zmp");
- var Builder = new CBuilder(WScript.Arguments.Named.Item("target"));
- var oFiles = Source.GetSourceFoldersEnumerator();
- for (; !oFiles.atEnd(); oFiles.moveNext()){
- var oFile = oFiles.item();
- if (Source.CheckExt(oFile)){
- Builder.ProcessFolder(oFile);
- };
- };
- };
- ]]>
-
- </script>
- </job>
|