mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 07:10:00 -06:00
Allow melonDS to write the file
The directory wasn't created, so the file was not being written
This commit is contained in:
@ -18,6 +18,11 @@
|
|||||||
|
|
||||||
#include "ArchiveUtil.h"
|
#include "ArchiveUtil.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <direct.h>
|
||||||
|
#define mkdir(dir, mode) _mkdir(dir)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Archive
|
namespace Archive
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -86,15 +91,17 @@ QVector<QString> ExtractFileFromArchive(const char* path, const char* wantedFile
|
|||||||
archiveBuffer.reset(nullptr);
|
archiveBuffer.reset(nullptr);
|
||||||
return QVector<QString> {"Err", archive_error_string(a)};
|
return QVector<QString> {"Err", archive_error_string(a)};
|
||||||
}
|
}
|
||||||
|
QString nameToWrite = QFileInfo(path).absolutePath() + "/" + QFileInfo(path).baseName() + "/" + archive_entry_pathname(entry);
|
||||||
|
|
||||||
QString fileToWrite = QFileInfo(path).absolutePath() + "/" + QFileInfo(path).baseName() + "/" + archive_entry_pathname(entry);
|
mkdir(QFileInfo(path).baseName().toUtf8().constData(), 600); // Create directory otherwise fopen will not open the file
|
||||||
|
FILE* fileToWrite = fopen(nameToWrite.toUtf8().constData(), "wb");
|
||||||
std::ofstream(fileToWrite.toUtf8().constData(), std::ofstream::binary).write((char*)archiveBuffer.get(), bytesToWrite);
|
fwrite((char*)archiveBuffer.get(), bytesToWrite, 1, fileToWrite);
|
||||||
|
fclose(fileToWrite);
|
||||||
|
|
||||||
archiveBuffer.reset(nullptr);
|
archiveBuffer.reset(nullptr);
|
||||||
archive_read_close(a);
|
archive_read_close(a);
|
||||||
archive_read_free(a);
|
archive_read_free(a);
|
||||||
return QVector<QString> {fileToWrite};
|
return QVector<QString> {nameToWrite};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
Reference in New Issue
Block a user