Add new err msg - thx darnn :)

Fix  #6878
This commit is contained in:
niksedk 2023-04-29 14:49:07 +02:00
parent c2f03d2762
commit 01bea6dc86
6 changed files with 29 additions and 0 deletions

View File

@ -1542,6 +1542,7 @@ To use an API key, go to "Options -> Settings -> Tools" to enter your Goog
<LoadedEmptyOrShort>Loaded empty or very short subtitle {0}</LoadedEmptyOrShort>
<FileIsEmptyOrShort>File is empty or very short!</FileIsEmptyOrShort>
<FileNotFound>File not found: {0}</FileNotFound>
<FileLocked>Unable to open file as it is in use by another program: {0}</FileLocked>
<SavedSubtitleX>Saved subtitle {0}</SavedSubtitleX>
<SavedOriginalSubtitleX>Saved original subtitle {0}</SavedOriginalSubtitleX>
<FileOnDiskModified>File on disk modified</FileOnDiskModified>

View File

@ -609,5 +609,22 @@ namespace Nikse.SubtitleEdit.Core.Common
return validator.IsValid;
}
}
public static bool IsFileLocked(string fileName)
{
try
{
using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.None))
{
stream.Close();
}
}
catch (IOException)
{
return true;
}
return false;
}
}
}

View File

@ -2756,6 +2756,12 @@ namespace Nikse.SubtitleEdit.Forms
return;
}
if (FileUtil.IsFileLocked(fileName))
{
MessageBox.Show(string.Format(_language.FileLocked, fileName));
return;
}
_lastAutoSave = DateTime.UtcNow.Ticks;
bool videoFileLoaded = false;
_formatManuallyChanged = false;

View File

@ -1447,6 +1447,7 @@ namespace Nikse.SubtitleEdit.Logic
LoadedEmptyOrShort = "Loaded empty or very short subtitle {0}",
FileIsEmptyOrShort = "File is empty or very short!",
FileNotFound = "File not found: {0}",
FileLocked = "Unable to open file as it is in use by another program: {0}",
SavedSubtitleX = "Saved subtitle {0}",
SavedOriginalSubtitleX = "Saved original subtitle {0}",
FileOnDiskModified = "File on disk modified",

View File

@ -3190,6 +3190,9 @@ namespace Nikse.SubtitleEdit.Logic
case "Main/FileNotFound":
language.Main.FileNotFound = reader.Value;
break;
case "Main/FileLocked":
language.Main.FileLocked = reader.Value;
break;
case "Main/SavedSubtitleX":
language.Main.SavedSubtitleX = reader.Value;
break;

View File

@ -1307,6 +1307,7 @@ namespace Nikse.SubtitleEdit.Logic
public string LoadedEmptyOrShort { get; set; }
public string FileIsEmptyOrShort { get; set; }
public string FileNotFound { get; set; }
public string FileLocked { get; set; }
public string SavedSubtitleX { get; set; }
public string SavedOriginalSubtitleX { get; set; }
public string FileOnDiskModified { get; set; }