Added check for another non subtitle file

This commit is contained in:
niksedk 2014-11-15 22:32:23 +01:00
parent 7d5a059f84
commit f9dc21b9a0
6 changed files with 30 additions and 0 deletions

View File

@ -1225,6 +1225,7 @@ Continue?</SubtitleAppendPrompt>
<ErrorLoadRar>This file seems to be a compressed .rar file. Subtitle Edit cannot open compressed files.</ErrorLoadRar>
<ErrorLoadZip>This file seems to be a compressed .zip file. Subtitle Edit cannot open compressed files.</ErrorLoadZip>
<ErrorLoadPng>This file seems to be a PNG image file. Subtitle Edit cannot open PNG files.</ErrorLoadPng>
<ErrorLoadSrr>This file seems to be a ReScene .srr file - not a subtitle file.</ErrorLoadSrr>
</Main>
<MatroskaSubtitleChooser>
<Title>Choose subtitle from Matroska file</Title>

View File

@ -115,6 +115,20 @@ namespace Nikse.SubtitleEdit.Core
}
}
public static bool IsSrr(string fileName)
{
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
var buffer = new byte[3];
var count = fs.Read(buffer, 0, buffer.Length);
if (count != buffer.Length)
return false;
return buffer[0] == 0x69
&& buffer[1] == 0x69
&& buffer[2] == 0x69;
}
}
public static bool IsBluRaySup(string fileName)
{
using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))

View File

@ -2824,6 +2824,16 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
// check for .srr file
if (format == null && fi.Length > 100 && ext == ".srr" && FileUtil.IsSrr(fileName))
{
if (string.IsNullOrEmpty(_language.ErrorLoadSrr))
MessageBox.Show("This file seems to be a ReScene .srr file - not a subtitle file.");
else
MessageBox.Show(_language.ErrorLoadSrr);
return;
}
if (format == null && fi.Length < 100 * 1000000 && TransportStreamParser.IsDvbSup(fileName))
{
ImportSubtitleFromDvbSupFile(fileName);

View File

@ -1133,6 +1133,7 @@ namespace Nikse.SubtitleEdit.Logic
ErrorLoadRar = "This file seems to be a compressed .rar file. Subtitle Edit cannot open compressed files.",
ErrorLoadZip = "This file seems to be a compressed .zip file. Subtitle Edit cannot open compressed files.",
ErrorLoadPng = "This file seems to be a PNG image file. Subtitle Edit cannot open PNG files.",
ErrorLoadSrr = "This file seems to be a ReScene .srr file - not a subtitle file.",
Menu = new LanguageStructure.Main.MainMenu
{

View File

@ -2624,6 +2624,9 @@ namespace Nikse.SubtitleEdit.Logic
case "Main/ErrorLoadPng":
language.Main.ErrorLoadPng = reader.Value;
break;
case "Main/ErrorLoadSrr":
language.Main.ErrorLoadSrr = reader.Value;
break;
case "Main/Menu/File/Title":
language.Main.Menu.File.Title = reader.Value;
break;

View File

@ -1018,6 +1018,7 @@
public string ErrorLoadRar { get; set; }
public string ErrorLoadZip { get; set; }
public string ErrorLoadPng { get; set; }
public string ErrorLoadSrr { get; set; }
public class MainMenu
{