Index: /CKEditor/trunk/_dev/langtool/includes/cklangtool.js
===================================================================
--- /CKEditor/trunk/_dev/langtool/includes/cklangtool.js	(revision 3102)
+++ /CKEditor/trunk/_dev/langtool/includes/cklangtool.js	(revision 3103)
@@ -4,5 +4,4 @@
 */
 
-importClass( java.io.DataInputStream );
 importPackage( java.util.regex );
 
@@ -135,109 +134,100 @@
 		fileOverviewBlock = '/**\n* @fileOverview \n*/';
 
-		try
-		{
-			var fstream = new FileInputStream( file );
-			var dis = new DataInputStream( fstream );
-			var br = new BufferedReader( new InputStreamReader( dis, "UTF-8" ) );
-			var key = "ckeditor_translation";
-			var out =
-			{};
-			var inBlockComment = false;
-			var blockComment = [];
-			var objectName, matcher, line, translationKey;
-
-			while ( (line = br.readLine()) != null )
-			{
-				if ( !inBlockComment )
-				{
-					matcher = regexLib.inlineComment.matcher( line );
+		var key = "ckeditor_translation";
+		var out =
+		{};
+		var inBlockComment = false;
+		var blockComment = [];
+		var objectName, matcher, line, translationKey;
+		var lines = CKLANGTOOL.io.readFileIntoArray( file );
+
+		for ( var j = 0 ; j < lines.length ; j++ )
+		{
+			line = lines[ j ];
+			if ( !inBlockComment )
+			{
+				matcher = regexLib.inlineComment.matcher( line );
+				if ( matcher.find() )
+				{
+					continue;
+				}
+
+				matcher = regexLib.blockCommentStart.matcher( line );
+				if ( matcher.find() )
+				{
+					inBlockComment = true;
+					blockComment.push( line );
+					continue;
+				}
+
+				matcher = regexLib.objectName.matcher( line );
+				if ( matcher.find() )
+				{
+					objectName = matcher.group( 1 );
+					continue;
+				}
+
+				if ( objectName )
+				{
+					matcher = regexLib.objectStart.matcher( line );
+					/*
+					 * We have found an opening bracket, key -> key.objectName
+					 */
 					if ( matcher.find() )
 					{
+						key = key + "." + objectName;
 						continue;
 					}
 
-					matcher = regexLib.blockCommentStart.matcher( line );
+					matcher = regexLib.objectEnd.matcher( line );
+					/*
+					 * We have found a closing bracket, key.objectName -> key
+					 */
 					if ( matcher.find() )
 					{
-						inBlockComment = true;
-						blockComment.push( line );
+						key = key.slice( 0, key.lastIndexOf( "." ) );
 						continue;
 					}
-
-					matcher = regexLib.objectName.matcher( line );
+				}
+
+				/*
+				 * Get rid of all escaped quotes, we don't need the exact content at this stage, just the key
+				 */
+				matcher = regexLib.entry.matcher( line.replaceAll( "\\\\'", "" ) );
+				if ( matcher.find() && regexLib.missing.matcher( line ).find() )
+				{
+					translationKey = key + "." + matcher.group( 2 );
+					translationKey = translationKey.replace( /^ckeditor_translation\./, "" );
+					out[ translationKey ] = true;
+				}
+
+				/* 
+				 * Get rid of all escaped quotes, we don't need the exact content at this stage, just the key.
+				 */
+				matcher = regexLib.arrayEntry.matcher( line.replaceAll( "\\\\'", "" ) );
+				if ( matcher.find() && regexLib.missing.matcher( line ).find() )
+				{
+					translationKey = key + "." + matcher.group( 2 );
+					translationKey = translationKey.replace( /^ckeditor_translation\./, "" );
+					out[ translationKey ] = true;
+				}
+			}
+			else
+			{
+				blockComment.push( line );
+
+				matcher = regexLib.blockCommentEnd.matcher( line );
+				if ( matcher.find() )
+				{
+					inBlockComment = false;
+
+					matcher = regexLib.fileOverview.matcher( blockComment.join( "" ) );
 					if ( matcher.find() )
 					{
-						objectName = matcher.group( 1 );
-						continue;
-					}
-
-					if ( objectName )
-					{
-						matcher = regexLib.objectStart.matcher( line );
-						/*
-						 * We have found an opening bracket, key -> key.objectName
-						 */
-						if ( matcher.find() )
-						{
-							key = key + "." + objectName;
-							continue;
-						}
-
-						matcher = regexLib.objectEnd.matcher( line );
-						/*
-						 * We have found a closing bracket, key.objectName -> key
-						 */
-						if ( matcher.find() )
-						{
-							key = key.slice( 0, key.lastIndexOf( "." ) );
-							continue;
-						}
-					}
-
-					/*
-					 * Get rid of all escaped quotes, we don't need the exact content at this stage, just the key
-					 */
-					matcher = regexLib.entry.matcher( line.replaceAll( "\\\\'", "" ) );
-					if ( matcher.find() && regexLib.missing.matcher( line ).find() )
-					{
-						translationKey = key + "." + matcher.group( 2 );
-						translationKey = translationKey.replace( /^ckeditor_translation\./, "" );
-						out[ translationKey ] = true;
-					}
-
-					/* 
-					 * Get rid of all escaped quotes, we don't need the exact content at this stage, just the key.
-					 */
-					matcher = regexLib.arrayEntry.matcher( line.replaceAll( "\\\\'", "" ) );
-					if ( matcher.find() && regexLib.missing.matcher( line ).find() )
-					{
-						translationKey = key + "." + matcher.group( 2 );
-						translationKey = translationKey.replace( /^ckeditor_translation\./, "" );
-						out[ translationKey ] = true;
-					}
-				}
-				else
-				{
-					blockComment.push( line );
-
-					matcher = regexLib.blockCommentEnd.matcher( line );
-					if ( matcher.find() )
-					{
-						inBlockComment = false;
-
-						matcher = regexLib.fileOverview.matcher( blockComment.join( "" ) );
-						if ( matcher.find() )
-						{
-							fileOverviewBlock = blockComment.join( "\n" );
-						}
-						blockComment = [];
-					}
-				}
-			}
-			dis.close();
-		}
-		catch ( e )
-		{
-			throw ("Cannot read file " + file.getAbsolutePath() + e.message);
+						fileOverviewBlock = blockComment.join( "\n" );
+					}
+					blockComment = [];
+				}
+			}
 		}
 
@@ -259,156 +249,148 @@
 	function createTemplate( file )
 	{
-		try
-		{
-			var fstream = new FileInputStream( file );
-			var dis = new DataInputStream( fstream );
-			var br = new BufferedReader( new InputStreamReader( dis, "UTF-8" ) );
-			var key = "ckeditor_translation";
-			var out = [];
-			var inBlockComment = false;
-			var blockComment = [];
-			var i, matcher, matchResult, objectName, string, line;
-			var arrayEntryItems, arrayEntryItemsMatcher, arrayEntryLineEnd, arrayEntryLine, arrayEntryKey;
-
-			while ( (line = br.readLine()) != null )
-			{
-				if ( !inBlockComment )
-				{
-					matcher = regexLib.inlineComment.matcher( line );
+		var key = "ckeditor_translation";
+		var out = [];
+		var inBlockComment = false;
+		var blockComment = [];
+		var i, matcher, matchResult, objectName, string, line;
+		var arrayEntryItems, arrayEntryItemsMatcher, arrayEntryLineEnd, arrayEntryLine, arrayEntryKey;
+		var lines = CKLANGTOOL.io.readFileIntoArray( file );
+
+		for ( var j = 0 ; j < lines.length ; j++ )
+		{
+			line = lines[ j ];
+
+			if ( !inBlockComment )
+			{
+				matcher = regexLib.inlineComment.matcher( line );
+				if ( matcher.find() )
+				{
+					out.push( line );
+					continue;
+				}
+
+				matcher = regexLib.blockCommentStart.matcher( line );
+				if ( matcher.find() )
+				{
+					inBlockComment = true;
+					blockComment.push( line );
+					continue;
+				}
+
+				matcher = regexLib.objectName.matcher( line );
+				if ( matcher.find() )
+				{
+					objectName = matcher.group( 1 );
+					out.push( line );
+					continue;
+				}
+
+				if ( objectName )
+				{
+					matcher = regexLib.objectStart.matcher( line );
+					/*
+					 * We have found an opening bracket, key -> key.objectName
+					 */
 					if ( matcher.find() )
 					{
+						key = key + "." + objectName;
 						out.push( line );
 						continue;
 					}
 
-					matcher = regexLib.blockCommentStart.matcher( line );
+					matcher = regexLib.objectEnd.matcher( line );
+					/*
+					 * We have found a closing bracket, key.objectName -> key
+					 */
 					if ( matcher.find() )
 					{
-						inBlockComment = true;
-						blockComment.push( line );
-						continue;
-					}
-
-					matcher = regexLib.objectName.matcher( line );
-					if ( matcher.find() )
-					{
-						objectName = matcher.group( 1 );
+						key = key.slice( 0, key.lastIndexOf( "." ) );
 						out.push( line );
 						continue;
 					}
-
-					if ( objectName )
-					{
-						matcher = regexLib.objectStart.matcher( line );
-						/*
-						 * We have found an opening bracket, key -> key.objectName
-						 */
-						if ( matcher.find() )
+				}
+
+				/* 
+				 * Find CKEDITOR.lang['en']
+				 */
+				matcher = regexLib.ckeditorLang.matcher( line );
+				if ( matcher.find() )
+				{
+					out.push( matcher.group( 1 ) + "'#ckeditor_translation.__languageCode#'" + matcher.group( 2 ) );
+					continue;
+				}
+
+				/* 
+				 * Get rid of all escaped quotes, we don't need the exact content at this stage, just the key.
+				 * We're changing here the entry into the key.
+				 * So 'Upload' becomes '#ckeditor_translation.Upload#' in our temporary template.  
+				 */
+				matcher = regexLib.entry.matcher( line.replaceAll( "\\\\'", "" ) );
+				if ( matcher.find() )
+				{
+					out.push( matcher.group( 1 ) + matcher.group( 2 ) + matcher.group( 3 ) + "#" + key + "." + matcher.group( 2 ) + "#"
+							+ matcher.group( 4 ) );
+					continue;
+				}
+
+				/* 
+				 * Get rid of all escaped quotes, we don't need the exact content at this stage, just the key.
+				 * We're changing here the entry into the key.
+				 * So ['AM', 'PM'] becomes 
+				 * ['#ckeditor_translation.DateAmPm[0]#', '#ckeditor_translation.DateAmPm[1]#'] 
+				 * in our temporary template.  
+				 */
+				matcher = regexLib.arrayEntry.matcher( line.replaceAll( "\\\\'", "" ) );
+				if ( matcher.find() )
+				{
+					i = 0;
+
+					arrayEntryLine = matcher.group( 1 ) + matcher.group( 2 ) + matcher.group( 3 );
+					arrayEntryKey = matcher.group( 2 );
+					arrayEntryLineEnd = matcher.group( 5 );
+					arrayEntryItems = matcher.group( 4 );
+
+					arrayEntryItemsMatcher = regexLib.arrayItemEntry.matcher( arrayEntryItems );
+					while ( arrayEntryItemsMatcher.find() )
+					{
+						matchResult = arrayEntryItemsMatcher.toMatchResult();
+						if ( i > 0 )
 						{
-							key = key + "." + objectName;
-							out.push( line );
-							continue;
+							arrayEntryLine += ", ";
 						}
-
-						matcher = regexLib.objectEnd.matcher( line );
-						/*
-						 * We have found a closing bracket, key.objectName -> key
-						 */
-						if ( matcher.find() )
-						{
-							key = key.slice( 0, key.lastIndexOf( "." ) );
-							out.push( line );
-							continue;
-						}
-					}
-
-					/* 
-					 * Find CKEDITOR.lang['en']
+						arrayEntryLine += "'#" + key + "." + arrayEntryKey + "[" + i + "]" + "#'";
+						i++;
+					}
+					arrayEntryLine += arrayEntryLineEnd;
+					out.push( arrayEntryLine );
+					continue;
+				}
+
+				out.push( line );
+			}
+			else
+			{
+				blockComment.push( line );
+
+				matcher = regexLib.blockCommentEnd.matcher( line );
+				if ( matcher.find() )
+				{
+					inBlockComment = false;
+
+					matcher = regexLib.fileOverview.matcher( blockComment.join( "" ) );
+					/**
+					 * Add a placeholder for the fileOverview section.
 					 */
-					matcher = regexLib.ckeditorLang.matcher( line );
 					if ( matcher.find() )
 					{
-						out.push( matcher.group( 1 ) + "'#ckeditor_translation.__languageCode#'" + matcher.group( 2 ) );
-						continue;
-					}
-
-					/* 
-					 * Get rid of all escaped quotes, we don't need the exact content at this stage, just the key.
-					 * We're changing here the entry into the key.
-					 * So 'Upload' becomes '#ckeditor_translation.Upload#' in our temporary template.  
-					 */
-					matcher = regexLib.entry.matcher( line.replaceAll( "\\\\'", "" ) );
-					if ( matcher.find() )
-					{
-						out.push( matcher.group( 1 ) + matcher.group( 2 ) + matcher.group( 3 ) + "#" + key + "." + matcher.group( 2 ) + "#"
-								+ matcher.group( 4 ) );
-						continue;
-					}
-
-					/* 
-					 * Get rid of all escaped quotes, we don't need the exact content at this stage, just the key.
-					 * We're changing here the entry into the key.
-					 * So ['AM', 'PM'] becomes 
-					 * ['#ckeditor_translation.DateAmPm[0]#', '#ckeditor_translation.DateAmPm[1]#'] 
-					 * in our temporary template.  
-					 */
-					matcher = regexLib.arrayEntry.matcher( line.replaceAll( "\\\\'", "" ) );
-					if ( matcher.find() )
-					{
-						i = 0;
-
-						arrayEntryLine = matcher.group( 1 ) + matcher.group( 2 ) + matcher.group( 3 );
-						arrayEntryKey = matcher.group( 2 );
-						arrayEntryLineEnd = matcher.group( 5 );
-						arrayEntryItems = matcher.group( 4 );
-
-						arrayEntryItemsMatcher = regexLib.arrayItemEntry.matcher( arrayEntryItems );
-						while ( arrayEntryItemsMatcher.find() )
-						{
-							matchResult = arrayEntryItemsMatcher.toMatchResult();
-							if ( i > 0 )
-							{
-								arrayEntryLine += ", ";
-							}
-							arrayEntryLine += "'#" + key + "." + arrayEntryKey + "[" + i + "]" + "#'";
-							i++;
-						}
-						arrayEntryLine += arrayEntryLineEnd;
-						out.push( arrayEntryLine );
-						continue;
-					}
-
-					out.push( line );
-				}
-				else
-				{
-					blockComment.push( line );
-
-					matcher = regexLib.blockCommentEnd.matcher( line );
-					if ( matcher.find() )
-					{
-						inBlockComment = false;
-
-						matcher = regexLib.fileOverview.matcher( blockComment.join( "" ) );
-						/**
-						 * Add a placeholder for the fileOverview section.
-						 */
-						if ( matcher.find() )
-						{
-							out.push( "#ckeditor_translation.__fileOverview#" );
-						}
-						else
-						{
-							out.push( blockComment.join( "\n" ) );
-						}
-						blockComment = [];
-					}
-				}
-			}
-			dis.close();
-		}
-		catch ( e )
-		{
-			throw ("Cannot read file " + file.getAbsolutePath() + e.message);
+						out.push( "#ckeditor_translation.__fileOverview#" );
+					}
+					else
+					{
+						out.push( blockComment.join( "\n" ) );
+					}
+					blockComment = [];
+				}
+			}
 		}
 
Index: /CKEditor/trunk/_dev/langtool/includes/io.js
===================================================================
--- /CKEditor/trunk/_dev/langtool/includes/io.js	(revision 3102)
+++ /CKEditor/trunk/_dev/langtool/includes/io.js	(revision 3103)
@@ -6,10 +6,10 @@
 importClass( java.io.BufferedReader );
 importClass( java.io.BufferedWriter );
+importClass( java.io.DataInputStream );
 importClass( java.io.File );
-importClass( java.io.FileWriter );
 importClass( java.io.FileOutputStream );
 importClass( java.io.FileInputStream );
+importClass( java.io.FileOutputStream );
 importClass( java.io.InputStreamReader );
-importClass( java.io.FileOutputStream );
 importClass( java.io.OutputStreamWriter );
 importClass( java.lang.StringBuffer );
@@ -17,62 +17,6 @@
 ( function()
 {
-	function copyFile( sourceLocation, targetLocation )
+	CKLANGTOOL.io =
 	{
-		try
-		{
-			var inStream = new FileInputStream( sourceLocation );
-			var outStream = new FileOutputStream( targetLocation );
-
-			var len, buf = new Packages.java.lang.reflect.Array.newInstance( java.lang.Byte.TYPE, 1024 );
-
-			while ( (len = inStream.read( buf )) != -1 )
-			{
-				outStream.write( buf, 0, len );
-			}
-			inStream.close();
-			outStream.close();
-		}
-		catch ( e )
-		{
-			throw "Cannot copy file:\n Source: " + sourceLocation.getCanonicalPath() + "\n Destination : "
-					+ targetLocation.getCanonicalPath() + "\n" + e.message;
-		}
-	}
-
-	CKLANGTOOL.io = {
-		copyFile :copyFile,
-
-		deleteDirectory : function( path )
-		{
-			var dir = new File( path );
-
-			if ( dir.isDirectory() )
-			{
-				var children = dir.list();
-				for ( var i = 0 ; i < children.length ; i++ )
-				{
-					if ( !this.deleteDirectory( new File( dir, children[i] ) ) )
-					{
-						return false;
-					}
-				}
-			}
-
-			return dir["delete"]();
-		},
-
-		deleteFile : function( path )
-		{
-			var f = new File( path );
-
-			if ( !f.exists() )
-				return true;
-
-			if ( !f.canWrite() )
-				throw "Cannot delete file: " + f.getAbsolutePath();
-
-			return f["delete"]();
-		},
-
 		saveFile : function( file, text, includeBom )
 		{
@@ -89,28 +33,4 @@
 			{
 				throw "Cannot save file:\n Path: " + file.getCanonicalPath() + "\n Eception details: " + e.message;
-			}
-		},
-
-		copy : function( sourceLocation, targetLocation )
-		{
-			if ( CKLANGTOOL.verbose )
-				print( "    Copy -> " + targetLocation.toString().replaceFirst( ".*?release(/|\\\\)?", '' ) );
-
-			if ( sourceLocation.isDirectory() )
-			{
-				if ( !targetLocation.exists() )
-				{
-					targetLocation.mkdir();
-				}
-
-				var children = sourceLocation.list();
-				for ( var i = 0 ; i < children.length ; i++ )
-				{
-					this.copy( new File( sourceLocation, children[i] ), new File( targetLocation, children[i] ) );
-				}
-			}
-			else
-			{
-				copyFile( sourceLocation, targetLocation );
 			}
 		},
@@ -154,38 +74,30 @@
 		},
 
-		getDirectoryInfo : function( file )
+		readFileIntoArray : function( file )
 		{
-			var path_iterator, current_file, files, result = {
-				files :0,
-				size :0
-			};
+			var out = [];
 
-			if ( !file.exists() )
-				return result;
+			try
+			{
+				var fstream = new FileInputStream( file );
+				var dis = new DataInputStream( fstream );
+				var br = new BufferedReader( new InputStreamReader( dis, "UTF-8" ) );
+				var line;
 
-			files = file.listFiles();
-
-			if ( !files )
-				return result;
-
-			path_iterator = (java.util.Arrays.asList( files )).iterator();
-
-			while ( path_iterator.hasNext() )
-			{
-				current_file = path_iterator.next();
-				if ( current_file.isFile() )
+				while ( (line = br.readLine()) != null )
 				{
-					result.size += current_file.length();
-					result.files++;
-				}
-				else
-				{
-					var info = this.getDirectoryInfo( current_file );
-					result.size += info.size;
-					result.files += info.files;
+					out.push( line );
 				}
 			}
+			catch ( e )
+			{
+				throw 'An I/O error occurred while reading the ' + file.getCanonicalPath() + ' file.';
+			}
+			finally
+			{
+				dis.close();
+			}
 
-			return result;
+			return out;
 		},
 
