Skip to content

Commit 60064da

Browse files
committed
rename FormatDetector to FormatFactory.
1 parent c8975c6 commit 60064da

File tree

8 files changed

+13
-12
lines changed

8 files changed

+13
-12
lines changed

Applications/Ice/Core/Sources/CompressionQueryValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ private void SetDestination(string src)
264264
if (!src.HasValue()) return;
265265

266266
var ext = Io.GetExtension(src).ToLowerInvariant();
267-
var obj = ext == ".exe" ? Format.Sfx : FormatDetector.FromExtension(ext);
267+
var obj = ext == ".exe" ? Format.Sfx : FormatFactory.FromExtension(ext);
268268
if (obj == Format.Unknown) return;
269269

270270
var fmt = obj == Format.GZip || obj == Format.BZip2 || obj == Format.XZ ? Format.Tar : obj;

Applications/Ice/Main/Sources/Presenters/Extract/ExtractFacade.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private void Invoke(ArchiveReader src, int index, ExtractDirectory dir)
165165
Retry(() => src.Save(Temp, item, GetProgress()));
166166

167167
var dest = Io.Combine(Temp, item.FullName);
168-
if (FormatDetector.From(dest) != Format.Tar) Move(item);
168+
if (FormatFactory.From(dest) != Format.Tar) Move(item);
169169
else
170170
{
171171
using var e = new ArchiveReader(dest, Password, src.Options);

Libraries/Core/Sources/ArchiveReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public ArchiveReader(string src, ArchiveOption options) : this(src, string.Empty
109109
///
110110
/* --------------------------------------------------------------------- */
111111
public ArchiveReader(string src, string password, ArchiveOption options) :
112-
this(FormatDetector.From(src), src, new(password), options) { }
112+
this(FormatFactory.From(src), src, new(password), options) { }
113113

114114
/* --------------------------------------------------------------------- */
115115
///
@@ -126,7 +126,7 @@ public ArchiveReader(string src, string password, ArchiveOption options) :
126126
///
127127
/* --------------------------------------------------------------------- */
128128
public ArchiveReader(string src, IQuery<string> password, ArchiveOption options) :
129-
this(FormatDetector.From(src), src, new(password), options) { }
129+
this(FormatFactory.From(src), src, new(password), options) { }
130130

131131
/* --------------------------------------------------------------------- */
132132
///

Libraries/Core/Sources/FormatDetector.cs renamed to Libraries/Core/Sources/FormatFactory.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ namespace Cube.FileSystem.SevenZip;
2525

2626
/* ------------------------------------------------------------------------- */
2727
///
28-
/// Formatter
28+
/// FormatFactory
2929
///
3030
/// <summary>
31-
/// Provides extended methods of the Format.
31+
/// Provides functionality to detect the archive format with the specified
32+
/// arguments.
3233
/// </summary>
3334
///
3435
/* ------------------------------------------------------------------------- */
35-
public static class FormatDetector
36+
public static class FormatFactory
3637
{
3738
#region Methods
3839

Libraries/Core/Sources/Internal/ArchiveExtension.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static string GetPath(this IInArchive src, int index, string path)
7878
if (dest.HasValue()) return dest;
7979

8080
var tmp = Io.GetBaseName(path);
81-
var fmt = FormatDetector.FromExtension(Io.GetExtension(tmp));
81+
var fmt = FormatFactory.FromExtension(Io.GetExtension(tmp));
8282
if (fmt != Format.Unknown) return Io.GetFileName(tmp);
8383

8484
var name = index == 0 ? Io.GetFileName(tmp) : $"{Io.GetFileName(tmp)}({index})";

Tests/Core/Sources/ArchiveWriterExTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void WithCjk(CodePage cp)
6161
}
6262

6363
using var ss = Io.Open(dest);
64-
Assert.That(FormatDetector.From(ss), Is.EqualTo(zip));
64+
Assert.That(FormatFactory.From(ss), Is.EqualTo(zip));
6565
}
6666

6767
/* --------------------------------------------------------------------- */

Tests/Core/Sources/ArchiveWriterTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public Format Save(string filename, Format format, string[] src, CompressionOpti
5858
obj.Clear();
5959
}
6060

61-
using (var obj = Io.Open(dest)) return FormatDetector.From(obj);
61+
using (var obj = Io.Open(dest)) return FormatFactory.From(obj);
6262
}
6363

6464
#endregion

Tests/Core/Sources/FormatTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public Format Detect(string filename)
7171
{
7272
var dest = Get(Guid.NewGuid().ToString("N"));
7373
Io.Copy(GetSource(filename), dest, true);
74-
return FormatDetector.From(dest);
74+
return FormatFactory.From(dest);
7575
}
7676

7777
/* --------------------------------------------------------------------- */
@@ -102,7 +102,7 @@ public Format Detect(string filename)
102102
/* --------------------------------------------------------------------- */
103103
[Test]
104104
public void FromFile_NotFound()=> Assert.That(
105-
FormatDetector.From(GetSource("NotFound.rar")),
105+
FormatFactory.From(GetSource("NotFound.rar")),
106106
Is.EqualTo(Format.Rar)
107107
);
108108

0 commit comments

Comments
 (0)