Fixed some bugs in command line subtitle conversion (also tested on Linux)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@905 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2012-01-08 09:10:08 +00:00
parent 12941e3af2
commit 7899c1968f
2 changed files with 12 additions and 11 deletions

View File

@ -197,7 +197,7 @@ namespace Nikse.SubtitleEdit.Forms
public Main()
{
try
//try
{
InitializeComponent();
@ -351,16 +351,17 @@ namespace Nikse.SubtitleEdit.Forms
FixLargeFonts();
}
catch (Exception exception)
{
Cursor = Cursors.Default;
MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace);
}
//catch (Exception exception)
//{
// Cursor = Cursors.Default;
// MessageBox.Show(exception.Message + Environment.NewLine + exception.StackTrace);
//}
}
private void BatchConvert(string[] args) // E.g.: /convert *.txt SubRip
{
const int ATTACH_PARENT_PROCESS = -1;
if (!Utilities.IsRunningOnMac() && !Utilities.IsRunningOnLinux())
AttachConsole(ATTACH_PARENT_PROCESS);
Console.WriteLine();
@ -382,10 +383,10 @@ namespace Nikse.SubtitleEdit.Forms
string inputDirectory = Directory.GetCurrentDirectory();
int indexOfDirectorySeparatorChar = pattern.LastIndexOf(Path.DirectorySeparatorChar.ToString());
if (indexOfDirectorySeparatorChar > 0)
if (indexOfDirectorySeparatorChar > 0 && indexOfDirectorySeparatorChar < pattern.Length)
{
pattern = pattern.Substring(indexOfDirectorySeparatorChar);
inputDirectory = pattern.Substring(0, indexOfDirectorySeparatorChar -1);
pattern = pattern.Substring(indexOfDirectorySeparatorChar+1);
inputDirectory = args[2].Substring(0, indexOfDirectorySeparatorChar);
}
int count = 0;

View File

@ -92,7 +92,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
public List<string> GetClasses(Subtitle subtitle)
{
var list = new List<string>();
if (subtitle.Header.ToLower().StartsWith("<style"))
if (!string.IsNullOrEmpty(subtitle.Header) && subtitle.Header.ToLower().StartsWith("<style"))
{
foreach (string line in subtitle.Header.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
{