Skip to content

Commit

Permalink
use of fs::path and added a comment for 2003 subfolder order
Browse files Browse the repository at this point in the history
  • Loading branch information
N4gtan committed Oct 1, 2024
1 parent f79a11f commit b1c9f67
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

Add `sudo` to the install command if necessary.

The default installation path is `C:\Program Files\mkpsxiso` on Windows or `/usr/local/bin` on Linux. You can change it to any directory by passing `--install-prefix` to the first command.
The default installation path is `C:\Program Files (x86)\mkpsxiso` on Windows or `/usr/local/bin` on Linux. You can change it to any directory by passing `--install-prefix` to the first command.

## Issues

Expand Down
18 changes: 9 additions & 9 deletions src/dumpsxiso/cue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ bool multiBinSeeker(const unsigned int sector, const cd::IsoDirEntries::Entry &e
return reader.SeekToSector(sector - cueFile.tracks[trackIndex - 1].endSector);
}

CueFile parseCueFile(std::filesystem::path& inputFile) {
std::ifstream file(inputFile);
std::filesystem::path filePath;
std::string line, fileType;
CueFile parseCueFile(fs::path& inputFile) {
CueFile cueFile;
unsigned int previousStartSector = 0;
std::string line, fileType;
std::ifstream file(inputFile);
fs::path filePath = inputFile;
unsigned int pauseStartSector = 1;
unsigned int previousStartSector = 0;

while (std::getline(file, line)) {
if (line.find("FILE") != std::string::npos) {
Expand All @@ -23,18 +23,19 @@ CueFile parseCueFile(std::filesystem::path& inputFile) {
TrackInfo &lastTrack = cueFile.tracks.back();
lastTrack.sizeInSectors = cueFile.totalSectors - lastTrack.startSector;
lastTrack.endSector = lastTrack.startSector + lastTrack.sizeInSectors;
cueFile.multiBIN = true;
}

size_t firstQuote = line.find("\"");
size_t lastQuote = line.rfind("\"");
filePath = inputFile.parent_path() / line.substr(firstQuote + 1, lastQuote - firstQuote - 1);
std::string fileName = line.substr(firstQuote + 1, lastQuote - firstQuote - 1);
filePath.replace_filename(fileName);
if (int64_t sectors = GetSize(filePath) / CD_SECTOR_SIZE; sectors < 1) {
printf("Error: Failed to get the file size for \"%s\"\n", filePath.filename().u8string().c_str());
printf("Error: Failed to get the file size for \"%s\"\n", fileName.c_str());
exit(EXIT_FAILURE);
}
else {
cueFile.totalSectors += sectors;
cueFile.multiBIN = true;
}

if (line.find("BINARY") != std::string::npos) {
Expand All @@ -46,7 +47,6 @@ CueFile parseCueFile(std::filesystem::path& inputFile) {

if (cueFile.tracks.empty()) {
inputFile = filePath;
cueFile.multiBIN = false;
}
}
else if (line.find("TRACK") != std::string::npos) {
Expand Down
4 changes: 2 additions & 2 deletions src/dumpsxiso/cue.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <vector>

struct TrackInfo {
std::filesystem::path filePath;
fs::path filePath;
std::string fileType;
std::string number;
std::string type;
Expand All @@ -21,5 +21,5 @@ struct CueFile {
std::vector<TrackInfo> tracks;
};

CueFile parseCueFile(std::filesystem::path& inputFile);
CueFile parseCueFile(fs::path& inputFile);
bool multiBinSeeker(const unsigned int sector, const cd::IsoDirEntries::Entry &entry, cd::IsoReader &reader, const CueFile &cueFile);
6 changes: 5 additions & 1 deletion src/mkpsxiso/iso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,15 @@ bool iso::DirTreeClass::WriteDirEntries(cd::IsoWriter* writer, const DIRENTRY& d
const DIRENTRY& entry = e.get();
if ( !entry.id.empty() )
{
// Games built with the 2003 mastering tool has different subfolder directory sort.
// Currently, I've only tested this with 2 games, so idk if this behavior is the same for all.
// Maybe the sort could be like PS2 CDVDGEN, which depends on the order the files were added to the program
// instead of a normal sort, in that case another approach would be needed, like adding the custom order to the xml.
if (*global::new_type && this->name != "<root>" && entry.type == EntryType::EntryDir) {
dirQueue.push(entry);
}
else {
writeOneEntry(entry);
writeOneEntry(entry);
}
}
}
Expand Down

0 comments on commit b1c9f67

Please # to comment.