-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added NKit support (both .gcz and .iso) WIT and nod aren't included anymore, they will be downloaded on first run
- Loading branch information
1 parent
5ceaacb
commit 152387f
Showing
31 changed files
with
613 additions
and
10,296 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
using Nanook.NKit; | ||
using System.IO; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace MP1_Trilogy_Rando_Generator | ||
{ | ||
class NKitManager | ||
{ | ||
static bool IsValidFilename(string value) | ||
{ | ||
return Regex.IsMatch(value, @"^[\w\-. ]+$"); | ||
} | ||
|
||
public static bool ExtractISO(string filename) | ||
{ | ||
bool result = true; | ||
if (!Directory.Exists(@".\tmp\nkit")) | ||
Directory.CreateDirectory(@".\tmp\nkit"); | ||
try | ||
{ | ||
using(var ndisc = new NDisc(null, File.OpenRead(filename))) | ||
{ | ||
if (ndisc == null) | ||
throw new System.Exception(); | ||
if (ndisc.ExtractBasicInfo().Id.Substring(0,6) != "R3ME01") | ||
throw new System.Exception(); | ||
ndisc.ExtractFiles(ext_f => true, | ||
(f, ext_f) => | ||
{ | ||
var path = @".\tmp\nkit\DATA\" + (ext_f.PartitionId == null ? @"sys" : @"files"); | ||
if (ext_f.Path != "") | ||
path += @"\" + ext_f.Path; | ||
if (!Directory.Exists(path)) | ||
Directory.CreateDirectory(path); | ||
using (var stream = File.OpenWrite(path + @"\" + ext_f.Name)) | ||
f.Copy(stream, ext_f.Length); | ||
}); | ||
} | ||
} | ||
catch | ||
{ | ||
result = false; | ||
} | ||
if (Directory.Exists(@".\Dats")) | ||
Directory.Delete(@".\Dats", true); | ||
if (Directory.Exists(@".\Processed")) | ||
Directory.Delete(@".\Processed", true); | ||
if (Directory.Exists(@".\Recovery")) | ||
Directory.Delete(@".\Recovery", true); | ||
if (!result) | ||
Directory.Delete(@".\tmp\nkit", true); | ||
return result; | ||
} | ||
} | ||
} |
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.