-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 18b933e
Showing
60 changed files
with
10,684 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Binary file not shown.
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,28 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25420.1 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PS2_Tools", "PS2_Tools\PS2_Tools.csproj", "{C15D7496-EB98-46A7-A9F6-FDC3C54A7858}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tester", "Tester\Tester.csproj", "{8EE5E84C-529B-443C-ACBF-FFA9CA55BD00}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{C15D7496-EB98-46A7-A9F6-FDC3C54A7858}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{C15D7496-EB98-46A7-A9F6-FDC3C54A7858}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{C15D7496-EB98-46A7-A9F6-FDC3C54A7858}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{C15D7496-EB98-46A7-A9F6-FDC3C54A7858}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{8EE5E84C-529B-443C-ACBF-FFA9CA55BD00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{8EE5E84C-529B-443C-ACBF-FFA9CA55BD00}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{8EE5E84C-529B-443C-ACBF-FFA9CA55BD00}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{8EE5E84C-529B-443C-ACBF-FFA9CA55BD00}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
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,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace PS2_Tools.BinCue | ||
{ | ||
|
||
public class BinChunk | ||
{ | ||
public const int SectorLength = 2352; | ||
public static bool Verbose; | ||
private const string CueExtension = ".cue"; | ||
|
||
static string outFileNameBase; | ||
static string cueFileName; | ||
|
||
public void Convert_To_ISO(string file,string outfile) | ||
{ | ||
string cueFileName = file; | ||
string outFileNameBase = outfile; | ||
|
||
//Track.TruncatePsx = true; | ||
|
||
CueFile cueFile; | ||
|
||
try | ||
{ | ||
cueFileName = Path.ChangeExtension(cueFileName, CueExtension); | ||
cueFile = new CueFile(cueFileName); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new ApplicationException($"Could not read CUE {cueFileName}:\n{e.Message}"); | ||
} | ||
|
||
Stream binStream; | ||
try | ||
{ | ||
binStream = File.OpenRead(cueFile.BinFileName); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new ApplicationException($"Could not open BIN {cueFile.BinFileName}: {e.Message}"); | ||
} | ||
|
||
Console.WriteLine(Environment.NewLine + "Writing tracks:"); | ||
foreach (Track curTrack in cueFile.TrackList) | ||
{ | ||
// Include track number when more than 1 track. | ||
string outFileName; | ||
if (cueFile.TrackList.Count > 1) | ||
outFileName = | ||
$"{outFileNameBase}{curTrack.TrackNumber:00}.{curTrack.FileExtension.ToString().ToLower()}"; | ||
else | ||
outFileName = $"{outFileNameBase}.{curTrack.FileExtension.ToString().ToLower()}"; | ||
curTrack.Write(binStream, outFileName); | ||
} | ||
} | ||
} | ||
} |
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,80 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace PS2_Tools.BinCue | ||
{ | ||
public class CueFile | ||
{ | ||
public readonly ArrayList TrackList = new ArrayList(); | ||
public readonly string BinFileName; | ||
private readonly string cueFilePath; | ||
|
||
public CueFile(string cueFilePath) | ||
{ | ||
this.cueFilePath = cueFilePath; | ||
Console.WriteLine("Reading the CUE file:"); | ||
string cueLines; | ||
using (TextReader cueReader = new StreamReader(cueFilePath)) | ||
{ | ||
BinFileName = GetBinFileName(cueReader.ReadLine()); | ||
cueLines = cueReader.ReadToEnd(); | ||
} | ||
|
||
Regex trackRegex = new Regex(@"track\s+?(\d+?)\s+?(\S+?)[\s$]+?index\s+?\d+?\s+?(\S*)", | ||
RegexOptions.IgnoreCase | RegexOptions.Multiline); | ||
var matches = trackRegex.Matches(cueLines); | ||
|
||
if (matches.Count == 0) | ||
throw new ApplicationException("No tracks was found."); | ||
|
||
Track track = null; | ||
Track prevTrack = null; | ||
foreach (Match trackMatch in matches) | ||
{ | ||
track = new Track( | ||
trackMatch.Groups[1].Value, | ||
trackMatch.Groups[2].Value, | ||
trackMatch.Groups[3].Value); | ||
|
||
if (BinChunk.Verbose) | ||
Console.WriteLine(" (StartSector {0} ofs {1})", track.StartSector, track.StartPosition); | ||
|
||
if (prevTrack != null) | ||
{ | ||
prevTrack.Stop = track.StartPosition - 1; | ||
prevTrack.StopSector = track.StartSector; | ||
} | ||
TrackList.Add(track); | ||
prevTrack = track; | ||
} | ||
|
||
if (track == null) return; | ||
track.Stop = GetBinFileLength(); | ||
track.StopSector = track.Stop / BinChunk.SectorLength; | ||
TrackList[TrackList.Count - 1] = track; | ||
} | ||
|
||
private long GetBinFileLength() | ||
{ | ||
var fileInfo = new FileInfo(BinFileName); | ||
return fileInfo.Length; | ||
} | ||
|
||
private string GetBinFileName(string cueFirstLine) | ||
{ | ||
Regex binRegex = new Regex(@"file\s+?""(.*?)""", RegexOptions.IgnoreCase | RegexOptions.Multiline); | ||
Match match = binRegex.Match(cueFirstLine); | ||
string res = match.Groups[1].Value; | ||
var cueDirectory = Path.GetDirectoryName(cueFilePath); | ||
res = Path.Combine(cueDirectory, Path.GetFileName(res)); | ||
if (!File.Exists(res)) | ||
res = Path.Combine(cueDirectory, Path.GetFileNameWithoutExtension(cueFilePath) + ".bin"); | ||
return res; | ||
} | ||
} | ||
} |
Oops, something went wrong.