Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ To undo it, remove the entries in Windows Security → App & browser control →
| **Video**⁵: MP4, MOV, MKV, WEBM, AVI, WMV, FLV, MPEG, Video CD (DAT), TS, M2TS, 3GP, OGV, VOB, …;<br>Wisenet WAVE / Nx Witness exports (NOV) read | MP4 (H.264, HEVC, AV1), WEBM, MOV, MKV, AVI, GIF, APNG, MP3, M4A, 720p, split into parts;<br>subtitle tracks kept (MKV, MP4, MOV, WebM);<br>subtitles (SRT, ASS, WebVTT) |
| **Audio**⁵: MP3, M4A, AAC, WAV, FLAC, OGG, OPUS, WMA, AIFF, AMR, APE, WavPack, TTA, DSD (DSF, DFF), DTS, AC3, E-AC3, …;<br>tracker modules (XM, IT, S3M) read | MP3, M4A (AAC, ALAC), M4R (iPhone ringtone), WAV, FLAC, OGG, OPUS, AAC, WavPack, TTA, W64, AC3, E-AC3 |
| **Subtitles**: SRT, ASS/SSA, WebVTT, SAMI (SMI), LRC, KRC, TTML, MicroDVD, SCC | each other as UTF-8 (Korean CP949 files read correctly) |
| **Archives**: ZIP, ANSYS Workbench (WBPZ), 7Z, RAR, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, GZ, ISO, CAB, DMG, ALZ, EGG, …;<br>JAR, NuGet (NUPKG), Android packages (APKS, XAPK, APKM, AAB), Adobe extensions (ZXP) read | extract, ZIP, 7Z, TAR, TAR.GZ;<br>any files → one ZIP; folders → ZIP, ISO (Joliet or UDF 2.01) |
| **Archives**: ZIP, ANSYS Workbench (WBPZ), 7Z, RAR, TAR, TAR.GZ, TAR.BZ2, TAR.XZ, GZ, ISO, CAB, DMG, ALZ, EGG, Garry's Mod addon (GMA), Valve pak (VPK), files packed into a Source map (BSP), …;<br>JAR, NuGet (NUPKG), Android packages (APKS, XAPK, APKM, AAB), Adobe extensions (ZXP) read | extract, ZIP, 7Z, TAR, TAR.GZ, GMA;<br>any files → one ZIP; folders → ZIP, ISO (Joliet or UDF 2.01), GMA |
| **CAD**: DWG, DXF<br>Gerber PCB layers (GBR, GTL, GBL, GTO, …) read;<br>G-code of 3D printers and CNC machines (GCODE, GCO, NGC) read | PDF, SVG, PNG, DWG ↔ DXF;<br>G-code → toolpath (from above or isometric) or the slicer's preview |
| **Fonts**: TTF, OTF, WOFF, WOFF2, EOT;<br>FON (Windows bitmap fonts) read | each other;<br>FON → one font per size |
| **Data**: JSON, JSON Lines, YAML, TOML, XML<br>vCard, iCalendar | each other, CSV and XLSX (tables);<br>vCard, iCalendar ↔ CSV |
| **3D models**: GLB, glTF, STL, OBJ (+ MTL), 3MF, PLY;<br>FBX read | each other, PNG preview |
| **3D models**: GLB, glTF, STL, OBJ (+ MTL), 3MF, PLY, studiomdl data (SMD);<br>FBX, Source engine model (MDL, with its VTF textures) read | each other, PNG preview;<br>MDL → QC + SMDs (decompiled, with physics and animations) |
| **Geospatial vectors**: Shapefile, GeoJSON, KML, KMZ, GPX<br>CSV with coordinates; Garmin FIT, OpenStreetMap (.osm) read | each other and CSV / XLSX / JSON;<br>projected data (UTM, Web Mercator, Lambert, Albers) comes out as WGS 84 longitude / latitude |

Unmarked formats work out of the box, without Office, Hancom Office or LibreOffice.
Expand Down
104 changes: 101 additions & 3 deletions docs/ENGINES.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Filee.Core/Formats/FormatFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ .. Enum.GetValues<FormatCategory>().Select(category => category.ToString().ToLow
"dts", "tar", "tgz", "tbz2", "txz", "tar7z", "tlz", "gz", "bz2", "xz", "lz", "lzma", "jar", "zxp", "nupkg", "apks",
"aab", "mcpack", "mcaddon", "mcworld", "mctemplate", "mrpack", "cab", "gerber",
"cpio", "deb", "rpm", "dwg", "ttf", "otf", "woff", "woff2", "ass", "ssa", "ttml", "scc", "glb", "gltf",
"stl", "obj", "3mf", "ply", "fbx", "gcode", "geojson", "kml", "kmz", "gpx", "shp", "fit", "osm", "xm", "it", "ani", "vtf"
"stl", "obj", "3mf", "ply", "fbx", "gcode", "geojson", "kml", "kmz", "gpx", "shp", "fit", "osm", "xm", "it", "ani", "vtf", "gma", "vpk", "bsp", "mdl", "smd"
]),
(FormatGrade.Legacy,
[
Expand All @@ -100,7 +100,7 @@ .. Enum.GetValues<FormatCategory>().Select(category => category.ToString().ToLow
// Layout, print, photo post-production, signs and embroidery.
(["psd", "psb", "exr", "hdr", "xcf", "kra", "pdn", "raw", "eps", "ps", "ai", "cdr", "plt", "dst"], ["design"]),
// Game textures and cutscenes, Minecraft packs and modpacks.
(["dds", "vtf", "usm", "bik", "mcpack", "mcaddon", "mcworld", "mctemplate", "mrpack"], ["game"]),
(["dds", "vtf", "usm", "bik", "mcpack", "mcaddon", "mcworld", "mctemplate", "mrpack", "gma", "vpk", "bsp", "mdl", "smd"], ["game"]),
// Medical imaging and astronomy.
(["dcm", "fits"], ["science"]),
// Software work: raw image formats of graphics tools, app icons and cursors, config and data files, flat XML
Expand Down
13 changes: 13 additions & 0 deletions src/Filee.Core/Formats/FormatRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,14 @@ public static class FormatRegistry
new("mcworld", "Minecraft world", FormatCategory.Archive, ["mcworld"]),
new("mctemplate", "Minecraft world template", FormatCategory.Archive, ["mctemplate"]),
new("mrpack", "Modrinth modpack", FormatCategory.Archive, ["mrpack"]),
// Garry's Mod addons (Steam Workshop), read and written by Filee as gmad does: addon.json gives the title, type,
// tags and ignores, and only the files Garry's Mod loads go in.
new("gma", "Garry's Mod addon (GMA)", FormatCategory.Archive, ["gma"]),
// Valve paks (Source engine games' files, "pak01_dir.vpk" with its "pak01_000.vpk" … parts), read by Filee; a PS
// Vita package under the same extension is a ZIP and goes to 7-Zip.
new("vpk", "Valve pak (VPK)", FormatCategory.Archive, ["vpk"], Writable: false),
// Source engine maps: the files packed into a map (its pakfile lump, a ZIP) unpack like an archive.
new("bsp", "Source map (BSP)", FormatCategory.Archive, ["bsp"], Writable: false),
new("cab", "CAB", FormatCategory.Archive, ["cab"], Writable: false),
new("cpio", "CPIO", FormatCategory.Archive, ["cpio"], Writable: false),
new("deb", "DEB", FormatCategory.Archive, ["deb"], Writable: false),
Expand Down Expand Up @@ -409,6 +417,11 @@ public static class FormatRegistry
new("3mf", "3MF", FormatCategory.Model3D, ["3mf"]),
new("ply", "PLY", FormatCategory.Model3D, ["ply"]),
new("fbx", "FBX", FormatCategory.Model3D, ["fbx"], Writable: false),
// Source engine models (Garry's Mod and other Source games), read with the .vvd and .vtx beside them and their
// textures from the "materials" folder above them.
new("mdl", "Source model (MDL)", FormatCategory.Model3D, ["mdl"], Writable: false),
// Studiomdl data, the text the Source engine's model compiler reads (from an MDL with its bones and weights).
new("smd", "Studiomdl data (SMD)", FormatCategory.Model3D, ["smd"]),

// Geospatial vector data (CSV with coordinates is a Data format and reaches these through the geo engine)
new("geojson", "GeoJSON", FormatCategory.Geo, ["geojson"]),
Expand Down
20 changes: 18 additions & 2 deletions src/Filee.Core/Presets/BuiltInData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ .. CatalogPresets(),
.. DataPresets(),
.. CodecAndSubtitlePresets(),
.. ModelPresets(),
.. SourceModelPresets(),
.. GeoPresets(),
.. TracePresets(),
];
Expand Down Expand Up @@ -226,8 +227,8 @@ public static List<Preset> ClipPresets() =>
];

/// <summary>
/// Minecraft packs and Modrinth modpacks (#824, #898, added to the library in settings schema 62): in the palette
/// only, after "TAR", in the Games field (off in a new install).
/// Minecraft packs and Modrinth modpacks (#824, #898, added to the library in settings schema 62) and Garry's Mod
/// addons (#1526, schema 96): in the palette only, after "TAR", in the Games field (off in a new install).
/// </summary>
public static List<Preset> GamePackPresets() =>
[
Expand All @@ -236,6 +237,7 @@ public static List<Preset> GamePackPresets() =>
new() { Id = "to-mcworld", Name = "MCWORLD", TargetFormat = "mcworld" },
new() { Id = "to-mctemplate", Name = "MCTEMPLATE", TargetFormat = "mctemplate" },
new() { Id = "to-mrpack", Name = "MRPACK", TargetFormat = "mrpack" },
new() { Id = "to-gma", Name = "GMA", TargetFormat = "gma" },
];

/// <summary>
Expand Down Expand Up @@ -590,6 +592,20 @@ public static List<Preset> ModelPresets() =>
new() { Id = "to-gltf", Name = "glTF", TargetFormat = "gltf" },
];

/// <summary>
/// Studiomdl data for Source engine models (#1526, added to the library in settings schema 97): in the palette only,
/// after glTF, in the Games field (off in a new install). "QC + SMD" decompiles a model into the folder studiomdl
/// builds it from (settings schema 98); only a .mdl can take it.
/// </summary>
public static List<Preset> SourceModelPresets() =>
[
new() { Id = "to-smd", Name = "SMD", TargetFormat = "smd" },
new() { Id = DecompileModelId, Name = "QC + SMD", TargetFormat = FormatRegistry.Folder },
];

/// <summary>The preset that decompiles a Source engine model (.mdl) into its QC and SMDs.</summary>
public const string DecompileModelId = "decompile-mdl";

/// <summary>
/// Geospatial vector targets (added in settings schema 25, see SettingsMigrations). CSV, the sixth slice of the
/// donut, is the spreadsheet preset. KMZ is a KML in a ZIP and is on no donut.
Expand Down
2 changes: 1 addition & 1 deletion src/Filee.Core/Settings/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public static bool IsFlipKeyAllowed(string key, IEnumerable<TriggerGesture> gest
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
public const int CurrentSchemaVersion = 94;
public const int CurrentSchemaVersion = 98;

public int SchemaVersion { get; set; } = CurrentSchemaVersion;

Expand Down
52 changes: 52 additions & 0 deletions src/Filee.Core/Settings/UserDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,27 @@ public static bool ApplyToLibrary(int from, List<Preset> presets, List<ToolbarPr
// v94: Valve textures (.vtf) learn the images donut; custom claims stay put.
if (from < 94)
changed |= LearnExtensions(profiles, out _, ["vtf"]);
// v95: Source engine files: Garry's Mod addons (.gma), Valve paks (.vpk) and maps (.bsp, for the files packed into
// them) learn the archives donut; custom claims stay put. (Schema 95 may be renumbered if another change
// takes it first.)
if (from < 95)
changed |= LearnExtensions(profiles, out _, ["gma", "vpk", "bsp"]);
// v96: "GMA" (packing a folder into a Garry's Mod addon) joins the game packs in the palette, not a donut; the
// game packs the user removed stay removed. (Schema 96 may be renumbered if another change takes it first.)
if (from < 96)
changed |= AddGma(presets);
// v97: Source engine models (.mdl) and studiomdl data (.smd) learn the 3D models donut and "SMD" joins the 3D
// models in the palette after glTF; custom claims stay put. (Schema 97 may be renumbered if another change
// takes it first.)
if (from < 97)
{
changed |= AddSourcePresets(presets);
changed |= LearnExtensions(profiles, out _, ["mdl", "smd"]);
}
// v98: "QC + SMD" (decompiling a Source engine model into its QC and SMDs) joins the palette after "SMD", not a
// donut. (Schema 98 may be renumbered if another change takes it first.)
if (from < 98 && presets.All(p => p.Id != BuiltInData.DecompileModelId))
changed |= AddLikeNewLibrary(presets, BuiltInData.DecompileModelId);
return changed;
}

Expand Down Expand Up @@ -1233,6 +1254,37 @@ private static bool AddGamePacks(List<Preset> presets)
return changed;
}

/// <summary>
/// "GMA" after the last game pack of the library (else after "TAR", else at the end); the game packs the user removed
/// stay removed.
/// </summary>
private static bool AddGma(List<Preset> presets)
{
if (presets.Any(p => p.Id == "to-gma"))
return false;
var packs = BuiltInData.GamePackPresets().Select(p => p.Id).ToHashSet();
var at = presets.FindLastIndex(p => packs.Contains(p.Id));
if (at < 0)
at = presets.FindIndex(p => p.Id == "to-tar");
presets.Insert(at < 0 ? presets.Count : at + 1, BuiltInData.GamePackPresets().Single(p => p.Id == "to-gma"));
return true;
}

/// <summary>"SMD" after the last 3D model preset of the library (glTF), or at the end.</summary>
private static bool AddSourcePresets(List<Preset> presets)
{
var changed = false;
// Only "SMD": "QC + SMD" came a step later.
foreach (var preset in BuiltInData.SourceModelPresets().Where(p => p.Id == "to-smd" && presets.All(existing => existing.Id != p.Id)))
{
var models = BuiltInData.ModelPresets().Select(p => p.Id).ToHashSet();
var last = presets.FindLastIndex(p => models.Contains(p.Id));
presets.Insert(last < 0 ? presets.Count : last + 1, preset);
changed = true;
}
return changed;
}

private static bool AddCropVideo(List<Preset> presets)
{
var at = presets.FindIndex(p => p.Id == "tool-clip");
Expand Down
19 changes: 11 additions & 8 deletions src/Filee.Engines/Archives/ArchiveConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Archives: unpack (to a folder, the "Extract" preset), convert between archive formats (ZIP, 7Z, TAR, TAR.GZ,
// TAR.BZ2, TAR.XZ, single-file GZ / BZ2 / XZ, and the Minecraft and Modrinth packs that are ZIPs, see GamePacks), and
// "Compress into one archive" for any files (IFileCombiner).
// TAR.BZ2, TAR.XZ, single-file GZ / BZ2 / XZ, the Minecraft and Modrinth packs that are ZIPs, see GamePacks, and Garry's
// Mod addons, see Gma), and "Compress into one archive" for any files (IFileCombiner).
// Reading uses the bundled 7-Zip (engines/7zip, LGPL, separate process) plus Filee's own ALZ, EGG and lzip readers;
// ZIP, TAR and TAR.GZ are written in-process, the other formats by 7-Zip. See docs/ENGINES.md.

Expand All @@ -16,7 +16,7 @@ namespace Filee.Engines.Archives;
public sealed class ArchiveConverter : IConverter, IFileCombiner
{
/// <summary>Archive formats Filee writes (plus <see cref="FormatRegistry.Folder"/>).</summary>
private static readonly string[] ArchiveTargets = ["zip", "7z", "tar", "tgz", "tbz2", "txz", .. GamePacks.Formats];
private static readonly string[] ArchiveTargets = ["zip", "7z", "tar", "tgz", "tbz2", "txz", "gma", .. GamePacks.Formats];

/// <summary>Compressed single files (no names or folders inside); they convert among each other.</summary>
private static readonly string[] SingleFileSources = ["gz", "bz2", "xz", "lzma", "z", "lz"];
Expand All @@ -38,7 +38,7 @@ .. from source in SingleFileSources
from target in ArchivePacker.SingleFileFormats
select new ConversionEdge(source, target),
.. ArchiveExtractor.ReadableFormats.Select(source => new ConversionEdge(source, "iso", DirectOnly: true)),
.. new[] { "zip", "7z", "tar", "tgz", "tbz2", "txz" }
.. new[] { "zip", "7z", "tar", "tgz", "tbz2", "txz", "gma" }
.Select(target => new ConversionEdge(FormatRegistry.Folder, target, DirectOnly: true)),
];

Expand Down Expand Up @@ -85,6 +85,8 @@ public async Task<IReadOnlyList<string>> ConvertAsync(ConversionStep step, IProg
}
if (GamePacks.Formats.Contains(step.To))
unpacked = GamePacks.Root(unpacked, step.To);
else if (step.To == "gma")
unpacked = Gma.Root(unpacked);
var items = Directory.EnumerateFileSystemEntries(unpacked)
.Order(StringComparer.Ordinal)
.Select(path => new PackItem(path, Path.GetFileName(path)))
Expand Down Expand Up @@ -141,10 +143,11 @@ public async Task CombineAsync(IReadOnlyList<string> inputPaths, string outputPa
string workDirectory, IProgress<double>? progress, CancellationToken cancellationToken)
{
var sevenZip = ArchivePacker.BuiltInFormats.Contains(format) ? null : _sevenZip ??= SevenZip.Locate();
// A pack made from its folder holds the folder's content, so its marker file is at the top.
var entries = GamePacks.Formats.Contains(format) && inputPaths is [var folder] && Directory.Exists(folder)
? Directory.EnumerateFileSystemEntries(GamePacks.Root(folder, format)).Order(StringComparer.Ordinal)
.Select(path => new PackItem(path, Path.GetFileName(path))).ToList()
// A pack (or a Garry's Mod addon) made from its folder holds the folder's content, so its marker file (addon.json)
// is at the top.
var entries = (GamePacks.Formats.Contains(format) || format == "gma") && inputPaths is [var folder] && Directory.Exists(folder)
? Directory.EnumerateFileSystemEntries(format == "gma" ? Gma.Root(folder) : GamePacks.Root(folder, format))
.Order(StringComparer.Ordinal).Select(path => new PackItem(path, Path.GetFileName(path))).ToList()
: UniqueEntries(inputPaths);
await new ArchivePacker(sevenZip).PackAsync(entries, outputPath, format, preset.Archive.Level,
workDirectory, progress, cancellationToken);
Expand Down
36 changes: 33 additions & 3 deletions src/Filee.Engines/Archives/ArchiveExtractor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Unpacks every archive format Filee reads into a folder: the bundled 7-Zip for most of them, Filee's own readers for
// ALZ, EGG and lzip. Compressed TARs (.tar.gz, .tar.lz …) and RPM payloads are unpacked stage by stage until the
// files appear. Every stage is checked first (encryption, paths leaving the folder, disk space) and links are removed.
// ALZ, EGG, lzip, Garry's Mod addons (GMA) and Valve paks (VPK); the files packed into a Source engine map (BSP) are a
// ZIP that Filee copies out for 7-Zip. Compressed TARs (.tar.gz, .tar.lz …) and RPM payloads are unpacked stage by
// stage until the files appear. Every stage is checked first (encryption, paths leaving the folder, disk space) and
// links are removed.
// A single compressed stream (.gz, .bz2 …) is written by Filee as 7-Zip decodes it, so it can't fill the drive. The
// archive's Mark of the Web goes onto the unpacked files.

Expand All @@ -25,7 +27,7 @@ internal sealed class ArchiveExtractor(SevenZip? sevenZip, Func<string, long>? s
];

/// <summary>Formats read by Filee's own code (lzip still needs 7-Zip's LZMA decoder).</summary>
public static readonly IReadOnlyList<string> BuiltInFormats = ["alz", "egg", "lz", "tlz"];
public static readonly IReadOnlyList<string> BuiltInFormats = ["alz", "egg", "lz", "tlz", "gma", "vpk", "bsp"];

/// <summary>Everything that can be unpacked.</summary>
public static IEnumerable<string> ReadableFormats => SevenZipFormats.Concat(BuiltInFormats);
Expand Down Expand Up @@ -85,6 +87,34 @@ private async Task ExtractOnceAsync(string archive, string format, string folder
await EggReader.ExtractAsync(archive, folder, sevenZip, scratchRoot, cancellationToken);
PassOnMark(archive, folder);
break;
case "gma":
await Task.Run(() => Gma.Extract(archive, folder, cancellationToken), cancellationToken);
PassOnMark(archive, folder);
break;
// A PS Vita package is a ZIP under the same extension.
case "vpk" when Vpk.IsZip(archive):
await ExtractOnceAsync(archive, "zip", folder, scratchRoot, cancellationToken);
break;
case "vpk":
await Task.Run(() => Vpk.Extract(archive, folder, cancellationToken), cancellationToken);
PassOnMark(archive, folder);
break;
case "bsp":
{
// The map's packed files are a ZIP inside it: copied out, then unpacked like any ZIP.
var pakfile = Path.Combine(scratchRoot, $"pakfile-{Guid.NewGuid():N}.zip");
try
{
await Task.Run(() => Bsp.ExtractPakfile(archive, pakfile, cancellationToken), cancellationToken);
await ExtractOnceAsync(pakfile, "zip", folder, scratchRoot, cancellationToken);
}
finally
{
ArchiveFiles.TryDeleteFile(pakfile);
}
PassOnMark(archive, folder);
break;
}
case "lz":
case "tlz":
var output = FormatRegistry.NameWithoutExtension(archive) + (format == "tlz" ? ".tar" : "");
Expand Down
Loading
Loading