mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Minor refact using TarReader
This commit is contained in:
parent
3d463eecec
commit
2bf6aa120c
@ -149,13 +149,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
fs.Close();
|
||||
|
||||
var tr = new TarReader(tempFileName);
|
||||
foreach (TarHeader th in tr.Files)
|
||||
using (var tr = new TarReader(tempFileName))
|
||||
{
|
||||
string fn = Path.Combine(dictionaryFolder, Path.GetFileName(th.FileName.Trim()));
|
||||
th.WriteData(fn);
|
||||
foreach (var th in tr.Files)
|
||||
{
|
||||
string fn = Path.Combine(dictionaryFolder, Path.GetFileName(th.FileName.Trim()));
|
||||
th.WriteData(fn);
|
||||
}
|
||||
}
|
||||
tr.Close();
|
||||
File.Delete(tempFileName);
|
||||
|
||||
Cursor = Cursors.Default;
|
||||
|
@ -1,9 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
public class TarReader
|
||||
public class TarReader : IDisposable
|
||||
{
|
||||
|
||||
public List<TarHeader> Files { get; private set; }
|
||||
@ -11,7 +12,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
public TarReader(string fileName)
|
||||
{
|
||||
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
OpenTarFile(fs);
|
||||
}
|
||||
|
||||
@ -29,7 +30,6 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
stream.Position = 0;
|
||||
while (pos + 512 < length)
|
||||
{
|
||||
|
||||
stream.Seek(pos, SeekOrigin.Begin);
|
||||
var th = new TarHeader(stream);
|
||||
if (th.FileSizeInBytes > 0)
|
||||
@ -45,5 +45,14 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
_stream.Close();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_stream != null)
|
||||
{
|
||||
_stream.Dispose();
|
||||
_stream = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user