mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 21:55:34 +08:00
use invariant case conversion methods.
This commit is contained in:
parent
dc9f0ebb44
commit
8a53d74d5e
@ -64,7 +64,7 @@ namespace GameRes
|
||||
/// </returns>
|
||||
public static ArcFile TryOpen (string filename)
|
||||
{
|
||||
var ext = new Lazy<string> (() => Path.GetExtension (filename).TrimStart ('.').ToLower());
|
||||
var ext = new Lazy<string> (() => Path.GetExtension (filename).TrimStart ('.').ToLowerInvariant());
|
||||
var file = new ArcView (filename);
|
||||
try
|
||||
{
|
||||
@ -74,7 +74,7 @@ namespace GameRes
|
||||
var range = FormatCatalog.Instance.LookupSignature<ArchiveFormat> (signature);
|
||||
// check formats that match filename extension first
|
||||
if (range.Skip(1).Any()) // if range.Count() > 1
|
||||
range = range.OrderByDescending (f => f.Extensions.First() == ext.Value);
|
||||
range = range.OrderByDescending (f => f.Extensions.Any() && f.Extensions.First() == ext.Value);
|
||||
foreach (var impl in range)
|
||||
{
|
||||
try
|
||||
|
@ -109,7 +109,7 @@ namespace GameRes
|
||||
|
||||
protected IResource ()
|
||||
{
|
||||
m_extensions = new string[] { Tag.ToLower() };
|
||||
m_extensions = new string[] { Tag.ToLowerInvariant() };
|
||||
m_signatures = new uint[] { Signature };
|
||||
}
|
||||
}
|
||||
@ -309,7 +309,7 @@ namespace GameRes
|
||||
{
|
||||
foreach (var ext in impl.Extensions)
|
||||
{
|
||||
m_extension_map.Add (ext.ToUpper(), impl);
|
||||
m_extension_map.Add (ext.ToUpperInvariant(), impl);
|
||||
}
|
||||
foreach (var signature in impl.Signatures)
|
||||
{
|
||||
@ -325,14 +325,14 @@ namespace GameRes
|
||||
public IEnumerable<IResource> LookupFileName (string filename)
|
||||
{
|
||||
string ext = Path.GetExtension (filename);
|
||||
if (null == ext)
|
||||
if (string.IsNullOrEmpty (ext))
|
||||
return new IResource[0];
|
||||
return LookupExtension (ext.TrimStart ('.'));
|
||||
}
|
||||
|
||||
public IEnumerable<IResource> LookupExtension (string ext)
|
||||
{
|
||||
return m_extension_map.GetValues (ext.ToUpper(), true);
|
||||
return m_extension_map.GetValues (ext.ToUpperInvariant(), true);
|
||||
}
|
||||
|
||||
public IEnumerable<Type> LookupExtension<Type> (string ext) where Type : IResource
|
||||
@ -357,9 +357,9 @@ namespace GameRes
|
||||
{
|
||||
Entry entry = null;
|
||||
string ext = Path.GetExtension (filename);
|
||||
if (null != ext)
|
||||
if (!string.IsNullOrEmpty (ext))
|
||||
{
|
||||
ext = ext.TrimStart ('.').ToUpper();
|
||||
ext = ext.TrimStart ('.').ToUpperInvariant();
|
||||
var range = m_extension_map.GetValues (ext, false);
|
||||
if (null != range)
|
||||
entry = range.First().CreateEntry();
|
||||
|
@ -189,7 +189,7 @@ namespace GARbro.GUI
|
||||
{
|
||||
using (var file = arc.OpenEntry (entry))
|
||||
{
|
||||
string source_ext = Path.GetExtension (entry.Name).TrimStart ('.').ToLower();
|
||||
string source_ext = Path.GetExtension (entry.Name).TrimStart ('.').ToLowerInvariant();
|
||||
if (target_format.Extensions.Any (ext => ext == source_ext))
|
||||
{
|
||||
// source extension matches target image format, copy file as is
|
||||
@ -201,9 +201,7 @@ namespace GARbro.GUI
|
||||
if (null == image)
|
||||
throw new InvalidFormatException (string.Format ("{1}: {0}", guiStrings.MsgUnableInterpret, entry.Name));
|
||||
string target_ext = target_format.Extensions.First();
|
||||
string outdir = Path.GetDirectoryName (entry.Name);
|
||||
string outname = Path.GetFileNameWithoutExtension (entry.Name)+'.'+target_ext;
|
||||
outname = Path.Combine (outdir, outname);
|
||||
string outname = Path.ChangeExtension (entry.Name, target_ext);
|
||||
Trace.WriteLine (string.Format ("{0} => {1}", entry.Name, outname), "ExtractImage");
|
||||
using (var outfile = arc.CreateFile (new Entry { Name = outname }))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user