﻿//-->
System.Class.RegisterNamespace("System.IO");System.Class.RegisterNamespace("System.IO.Directory");System.IO.Directory.CreateDirectory=function(path){var folderInfo=null;var fso=new ActiveXObject("Scripting.FileSystemObject");var pathPhysical=new String(path);if(pathPhysical.indexOf(":")== -1){pathPhysical=Server.MapPath(path);}var arrPath=new Array;var regex=new RegExp("\\\\","g");arrPath=pathPhysical.split(regex);var pathTemp=new String;for(var i=0;i<arrPath.length;i++){var folderName=arrPath[i];if(i>0)pathTemp+="\\";pathTemp+=folderName;if(i>0){if(!fso.FolderExists(pathTemp)){Trace.Write("Create folder: "+pathTemp);try{fso.CreateFolder(pathTemp);folderInfo=fso.GetFolder(pathTemp);}catch(ex){}}}}return folderInfo;};System.IO.Directory.GetItems=function(path,searchPattern,typeIsFiles){var fso=new ActiveXObject("Scripting.FileSystemObject");var f=fso.GetFolder(path);var fc=new Enumerator((typeIsFiles)?f.Files:f.SubFolders);var items=new Array();var pattern=new String;pattern=(searchPattern)?searchPattern:".*";var regExp=new RegExp(pattern);var name=new String;for(;!fc.atEnd();fc.moveNext()){var item=fc.item();var isMatch=(item.Name.match(regExp)!=null);if(isMatch)items.push(item);}return items;};System.IO.Directory.GetFiles=function(path,searchPattern){return System.IO.Directory.GetItems(path,searchPattern,true);};System.IO.Directory.GetDirectories=function(path,searchPattern){return System.IO.Directory.GetItems(path,searchPattern,false);};System.Class.RegisterNamespace("System.IO.File");System.IO.File.ReadAllText=function(path){if(true){var ForReading=1,ForWriting=2,ForAppending=8;var TristateUseDefault= -2;var TristateTrue= -1;var TristateFalse=0;var fdo=new ActiveXObject("Scripting.FileSystemObject");var textStream=fso.OpenTextFile(path,ForReading);var content=new String;content=textStream.ReadAll();textStream.Close();delete textStream;return content;}else{var adTypeBinary=1,adTypeText=2,adSaveCreateOverWrite=2;var binaryStream=Server.CreateObject("ADODB.Stream");binaryStream.Type=adTypeBinary;binaryStream.Open();binaryStream.LoadFromFile(path);var results=binaryStream.Read();delete binaryStream;return results;}};System.IO.File.WriteAllText=function(path,contents,encoding){if(typeof(contents)=="string"){var ForReading=1,ForWriting=2,ForAppending=8;var fileSystem=new ActiveXObject("Scripting.FileSystemObject");var textStream=fileSystem.CreateTextFile(path);textStream.Write(contents);textStream.Close();delete textStream;}else{var adTypeBinary=1,adTypeText=2,adSaveCreateOverWrite=2;var binaryStream=Server.CreateObject("ADODB.Stream");binaryStream.Type=adTypeBinary;if(encoding!=null)binaryStream.CharSet=encoding;binaryStream.Open();try{binaryStream.Write(contents);}catch(ex){};binaryStream.SaveToFile(path,adSaveCreateOverWrite);delete binaryStream;}};System.IO.File.Delete=function(path,force){var fso=new ActiveXObject("Scripting.FileSystemObject");force=(force==true);return fso.DeleteFile(path,force);};System.IO.File.Exists=function(path){var fso=new ActiveXObject("Scripting.FileSystemObject");return fso.FileExists(path);};System.IO.File.Move=function(sourceFileName,destFileName){var fso=new ActiveXObject("Scripting.FileSystemObject");return fso.MoveFile(sourceFileName,destFileName);};System.IO.Path=function(){this.AltDirectorySeparatorChar='/';this.DirectorySeparatorChar='\\';this.ERROR_SUCCESS=0;this.InternalInvalidPathChars=['"','<','>','|','\0','\b','\x0010','\x0011','\x0012','\x0014','\x0015','\x0016','\x0017','\x0018','\x0019'];this.InvalidPathChars=['"','<','>','|','\0','\b','\x0010','\x0011','\x0012','\x0014','\x0015','\x0016','\x0017','\x0018','\x0019'];this.MAX_DIRECTORY_PATH=0xf8;this.MAX_PATH=260;this.PathSeparator=';';this.VolumeSeparatorChar=':';this.CheckInvalidPathChars=function(path){var iipc=new RegExp("["+this.InternalInvalidPathChars.toString().replace(",","","g")+"]");var isInvalid=(path.match(iipc))?true:false;return isInvalid;};this.FixupPath=function(path){return path;};this.IsDirectorySeparator=function(c){return(c==this.AltDirectorySeparatorChar||c==this.DirectorySeparatorChar);};this.GetRootLength=function(path){if(!this.CheckInvalidPathChars(path)){var num=0;var length=path.length;if((length>=1)&&this.IsDirectorySeparator(path.charAt(0))){num=1;if((length>=2)&&this.IsDirectorySeparator(path.charAt(1))){num=2;var num3=2;while((num<length)&&(((path.charAt(num)!=this.DirectorySeparatorChar)&&(path.charAt(num)!=this.AltDirectorySeparatorChar))||(--num3>0))){num++;}}return num;}if((length>=2)&&(path.charAt(1)==this.VolumeSeparatorChar)){num=2;if((length>=3)&&this.IsDirectorySeparator(path.charAt(2))){num++;}}return num;}};this.GetDirectoryName=function(path){if(path!=null){var isInvalid=this.CheckInvalidPathChars(path);path=this.FixupPath(path);var rootLength=this.GetRootLength(path);if(path.length>rootLength){var length=path.length;if(length==rootLength){return null;}while(((length>rootLength)&&(path.charAt(--length)!=this.DirectorySeparatorChar))&&(path.charAt(length)!=this.AltDirectorySeparatorChar)){}return path.substr(0,length);}}return null;};this.GetExtension=function(path){if(path!=null){if(!this.CheckInvalidPathChars(path)){var length=path.length;var startIndex=length;while(--startIndex>=0){var ch=path.charAt(startIndex);if(ch=='.'){if(startIndex!=(length-1)){return path.substr(startIndex,length-startIndex);}return "";}if(((ch==this.DirectorySeparatorChar)||(ch==this.AltDirectorySeparatorChar))||(ch==this.VolumeSeparatorChar)){break;}}return "";}}};this.GetFileName=function(path){if(path!=null){if(!this.CheckInvalidPathChars(path)){var length=path.length;var num2=length;while(--num2>=0){var ch=path.charAt(num2);if(((ch==this.DirectorySeparatorChar)||(ch==this.AltDirectorySeparatorChar))||(ch==this.VolumeSeparatorChar)){return path.substr(num2+1,(length-num2)-1);}}}}return path;};this.GetFileNameWithoutExtension=function(path){path=this.GetFileName(path);if(path==null){return null;}var length=path.lastIndexOf('.');if(length== -1){return path;}return path.substr(0,length);};this.HasExtension=function(path){if(path!=null){if(!this.CheckInvalidPathChars(path)){var length=path.length;while(--length>=0){var ch=path.charAt(length);if(ch=='.'){return(length!=(path.length-1));}if(((ch==this.DirectorySeparatorChar)||(ch==this.AltDirectorySeparatorChar))||(ch==this.VolumeSeparatorChar)){break;}}}}return false;};this.GetPathRoot=function(path){if(path==null){return null;}path=this.FixupPath(path);return path.substr(0,this.GetRootLength(path));};this.IsPathRooted=function(path){if(path!=null){if(!this.CheckInvalidPathChars(path)){var length=path.length;if(((length>=1)&&((path.charAt(0)==this.DirectorySeparatorChar)||(path.charAt(0)==this.AltDirectorySeparatorChar)))||((length>=2)&&(path.charAt(1)==this.VolumeSeparatorChar))){return true;}}}return false;};this.Combine=function(path1,path2){if(path1!=null&&path2!=null){if(!(this.CheckInvalidPathChars(path1)||this.CheckInvalidPathChars(path2))){if(path2.length==0){return path1;}if(path1.length==0){return path2;}if(this.IsPathRooted(path2)){return path2;}var ch=path1.charAt(path1.length-1);if(((ch!=this.DirectorySeparatorChar)&&(ch!=this.AltDirectorySeparatorChar))&&(ch!=this.VolumeSeparatorChar)){return(path1+this.DirectorySeparatorChar+path2);}return(path1+path2);}}};this.Initialize=function(){};this.Initialize.apply(this,arguments);};System.IO.MemoryStream=function(buffer){this.Type="System.IO.MemoryStream";this.Buffer=new Array();this.Capacity=0;this.Length=0;this.Position=0;var isServerSide=false;var stream=null;var adTypeBinary=1,adTypeText=2,adSaveCreateOverWrite=2;this.Read=function(buffer,offset,count){if(isServerSide){}else{for(var i=0;i<count;i++){buffer[offset+i]=this.Buffer[this.Position+i];}this.Position+=count;}};this.ToArray=function(){var array=new Array();if(isServerSide){}else{array=this.Buffer.slice(0,this.Buffer.length);}return array;};this.Flush=function(){if(isServerSide){}else{}};this.Write=function(buffer,offset,count){if(isServerSide){}else{for(var i=0;i<count;i++){this.Buffer[this.Position+i]=buffer[offset+i];}this.Position+=count;}};this.WriteTo=function(stream){if(isServerSide){}else{stream.Write(this.Buffer,0,this.Buffer.length);}};this.Close=function(){if(isServerSide){stream.Close();}};this.Dispose=function(){delete this.Buffer;delete this.Stream;};this.Initialize=function(){if(isServerSide){stream=Server.CreateObject("ADODB.Stream");stream.Type=adTypeBinary;stream.Open();}else{if(arguments[0]){var buffer=arguments[0];this.Write(buffer,0,buffer.length);}}};this.Initialize.apply(this,arguments);}
