Compare commits
No commits in common. "master" and "v1.2.0" have entirely different histories.
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using GarrysMod.AddonCreator.Hashing;
|
using GarrysMod.AddonCreator.Hashing;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
@ -245,7 +246,7 @@ namespace GarrysMod.AddonCreator.Addon
|
||||||
.ToDictionary(i => i.Key, i => i.Value);
|
.ToDictionary(i => i.Key, i => i.Value);
|
||||||
|
|
||||||
files = files
|
files = files
|
||||||
.Select(f => typeof(SupportedMimeType).Assembly
|
.Select(f => Assembly.LoadFrom("taglib-sharp.dll")
|
||||||
.GetTypes()
|
.GetTypes()
|
||||||
.Where(t => t.IsSubclassOf(typeof (TagLib.File)))
|
.Where(t => t.IsSubclassOf(typeof (TagLib.File)))
|
||||||
.Any(mediaSupport => mediaSupport.GetCustomAttributes(typeof (SupportedMimeType), false)
|
.Any(mediaSupport => mediaSupport.GetCustomAttributes(typeof (SupportedMimeType), false)
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
using System.Text;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace GarrysMod.AddonCreator.Addon
|
namespace GarrysMod.AddonCreator.Addon
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using TagLib;
|
using TagLib;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
|
|
||||||
|
@ -23,7 +26,6 @@ namespace GarrysMod.AddonCreator.Addon
|
||||||
/// Creates a new <see cref="MinifiedMediaAddonFileInfo"/> instance using the given addon file.
|
/// Creates a new <see cref="MinifiedMediaAddonFileInfo"/> instance using the given addon file.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="file">The addon file, supposedly a media file</param>
|
/// <param name="file">The addon file, supposedly a media file</param>
|
||||||
/// <param name="extension">The extension of this media file</param>
|
|
||||||
public MinifiedMediaAddonFileInfo(AddonFileInfo file, string extension)
|
public MinifiedMediaAddonFileInfo(AddonFileInfo file, string extension)
|
||||||
{
|
{
|
||||||
_tempFile = Path.GetTempFileName();
|
_tempFile = Path.GetTempFileName();
|
||||||
|
@ -35,8 +37,6 @@ namespace GarrysMod.AddonCreator.Addon
|
||||||
var newTempFile = Path.Combine(
|
var newTempFile = Path.Combine(
|
||||||
dirName,
|
dirName,
|
||||||
Path.GetFileNameWithoutExtension(_tempFile) + "." + extension);
|
Path.GetFileNameWithoutExtension(_tempFile) + "." + extension);
|
||||||
if (File.Exists(newTempFile))
|
|
||||||
File.Delete(newTempFile);
|
|
||||||
File.Move(_tempFile, newTempFile);
|
File.Move(_tempFile, newTempFile);
|
||||||
_tempFile = newTempFile;
|
_tempFile = newTempFile;
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ namespace GarrysMod.AddonCreator.Addon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var tags = TagLib.File.Create(new FileAbstraction(_tempFile)))
|
using (var s = new FileStream(_tempFile, FileMode.Open, FileAccess.Read))
|
||||||
|
using (var tags = TagLib.File.Create(new StreamFileAbstraction(_tempFile, s, s)))
|
||||||
{
|
{
|
||||||
if (tags.PossiblyCorrupt && !IgnoreCorrupted)
|
if (tags.PossiblyCorrupt && !IgnoreCorrupted)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
using System.IO;
|
|
||||||
using File = TagLib.File;
|
|
||||||
|
|
||||||
namespace GarrysMod.AddonCreator
|
|
||||||
{
|
|
||||||
class FileAbstraction : File.IFileAbstraction
|
|
||||||
{
|
|
||||||
private readonly string path;
|
|
||||||
private readonly MemoryStream realWriteStream;
|
|
||||||
public FileAbstraction(string path)
|
|
||||||
{
|
|
||||||
this.path = path;
|
|
||||||
realWriteStream = new MemoryStream();
|
|
||||||
WriteStream = new NonClosingStream(realWriteStream);
|
|
||||||
ReadStream = new FileStream(path, FileMode.Open, FileAccess.Read);
|
|
||||||
|
|
||||||
ReadStream.CopyTo(realWriteStream);
|
|
||||||
ReadStream.Position = realWriteStream.Position = 0;
|
|
||||||
|
|
||||||
Name = Path.GetFileName(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name { get; private set; }
|
|
||||||
|
|
||||||
public Stream ReadStream { get; private set; }
|
|
||||||
|
|
||||||
public Stream WriteStream { get; private set; }
|
|
||||||
|
|
||||||
public void CloseStream(Stream stream)
|
|
||||||
{
|
|
||||||
ReadStream.Dispose();
|
|
||||||
|
|
||||||
if (!((NonClosingStream) WriteStream).Written)
|
|
||||||
return;
|
|
||||||
|
|
||||||
realWriteStream.Position = 0;
|
|
||||||
using (var s = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
|
|
||||||
{
|
|
||||||
realWriteStream.CopyTo(s);
|
|
||||||
}
|
|
||||||
realWriteStream.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -69,10 +69,8 @@
|
||||||
<Compile Include="Addon\MinifiedMediaAddonFileInfo.cs" />
|
<Compile Include="Addon\MinifiedMediaAddonFileInfo.cs" />
|
||||||
<Compile Include="Extensions.cs" />
|
<Compile Include="Extensions.cs" />
|
||||||
<Compile Include="Addon\JsonAddonFileInfo.cs" />
|
<Compile Include="Addon\JsonAddonFileInfo.cs" />
|
||||||
<Compile Include="FileAbstraction.cs" />
|
|
||||||
<Compile Include="Hashing\Crc32.cs" />
|
<Compile Include="Hashing\Crc32.cs" />
|
||||||
<Compile Include="Addon\PhysicalAddonFileInfo.cs" />
|
<Compile Include="Addon\PhysicalAddonFileInfo.cs" />
|
||||||
<Compile Include="NonClosingStream.cs" />
|
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Addon\SegmentedAddonFileInfo.cs" />
|
<Compile Include="Addon\SegmentedAddonFileInfo.cs" />
|
||||||
|
|
|
@ -1,76 +0,0 @@
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace GarrysMod.AddonCreator
|
|
||||||
{
|
|
||||||
class NonClosingStream : Stream
|
|
||||||
{
|
|
||||||
private readonly Stream _stream;
|
|
||||||
|
|
||||||
public NonClosingStream(Stream stream)
|
|
||||||
{
|
|
||||||
_stream = stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanRead
|
|
||||||
{
|
|
||||||
get { return _stream.CanRead; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanSeek
|
|
||||||
{
|
|
||||||
get { return _stream.CanSeek; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CanWrite
|
|
||||||
{
|
|
||||||
get { return _stream.CanWrite; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Length
|
|
||||||
{
|
|
||||||
get { return _stream.Length; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Position
|
|
||||||
{
|
|
||||||
get { return _stream.Position; }
|
|
||||||
set { _stream.Position = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Flush()
|
|
||||||
{
|
|
||||||
_stream.Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Close()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override long Seek(long offset, SeekOrigin origin)
|
|
||||||
{
|
|
||||||
return _stream.Seek(offset, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SetLength(long value)
|
|
||||||
{
|
|
||||||
_stream.SetLength(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int Read(byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
return _stream.Read(buffer, offset, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(byte[] buffer, int offset, int count)
|
|
||||||
{
|
|
||||||
_stream.Write(buffer, offset, count);
|
|
||||||
Written = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Written { get; private set; }
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue