--[[
Function: TextUnixToWindows
Purpose: Converts a Unix text string to Windows format
Arguments: strText - The Unix text
Returns: The Windows string
Notes: If the string is already in Windows format, it is returned as-is
]]--
function TextUnixToWindows(strText)
	if (String.Find(strText,"\r\n") ~= nil) then
		-- It is already a Windows string...
		return strText;
	else
		strReturn = String.Replace(strText,"\n","\r\n");
		return strReturn;
	end
end

--[[
Function: TextFileUnixToWindows
Purpose: Converts a Unix text file to Windows format
Arguments: strFileName - The name of the Unix text file
Returns: nothing
]]--
function TextFileUnixToWindows(strFileName)
	strText = TextFile.ReadToString(strFileName);
	if (Application.GetLastError() == 0) then
		strConverted = TextUnixToWindows(strText);
		File.Delete(strFileName);
		TextFile.WriteFromString(strFileName,strConverted);
	end
end

--[[
Function: TextWindowsToUnix
Purpose: Converts a Windows text string to Unix format
Arguments: strText - The Windows text
Returns: The Unix string
Notes: If the string is already in Unix format, it is returned as-is
]]--
function TextWindowsToUnix(strText)
	if (String.Find(strText,"\r\n") == nil) then
		-- It is already a Unix string...
		return strText;
	else
		strReturn = String.Replace(strText,"\r\n","\n");
		return strReturn;
	end
end

--[[
Function: TextFileWindowsToUnix
Purpose: Converts a Windows text file to Unix format
Arguments: strFileName - The name of the Windows text file
Returns: nothing
]]--
function TextFileWindowsToUnix(strFileName)
	strText = TextFile.ReadToString(strFileName);
	if (Application.GetLastError() == 0) then
		strConverted = TextWindowsToUnix(strText);
		File.Delete(strFileName);
		TextFile.WriteFromString(strFileName,strConverted);
	end
end
