-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Corona-Studio:master' into master
- Loading branch information
Showing
124 changed files
with
2,394 additions
and
754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using ProjBobcat.Class.Model; | ||
using SharpCompress.Archives; | ||
|
||
namespace ProjBobcat.Class.Helper; | ||
|
||
public static class FileTypeHelper | ||
{ | ||
public static async Task<AssetFileType> TryDetectFileTypeAsync(string filePath) | ||
{ | ||
if (!File.Exists(filePath)) throw new IOException("File not found."); | ||
|
||
var extension = Path.GetExtension(filePath); | ||
|
||
switch (extension) | ||
{ | ||
case ".mrpack": | ||
return AssetFileType.ModrinthModPack; | ||
case ".zip": | ||
{ | ||
await using var fs = File.OpenRead(filePath); | ||
using var archive = ArchiveFactory.Open(fs); | ||
|
||
if (archive.Entries.Any(e => e.Key.Equals("manifest.json", StringComparison.OrdinalIgnoreCase))) | ||
return AssetFileType.CurseForgeModPack; | ||
if (archive.Entries.Any(e => e.Key.Equals("modrinth.index.json", StringComparison.OrdinalIgnoreCase))) | ||
return AssetFileType.ModrinthModPack; | ||
break; | ||
} | ||
} | ||
|
||
return AssetFileType.Unknown; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.