mirror of
https://github.com/autc04/Retro68.git
synced 2024-11-29 12:50:35 +00:00
fix reading/writing of real resource files on the mac
This commit is contained in:
parent
a6d2873ed6
commit
5426b3a741
@ -161,19 +161,36 @@ bool ResourceFile::read()
|
|||||||
{
|
{
|
||||||
case Format::basilisk:
|
case Format::basilisk:
|
||||||
{
|
{
|
||||||
fs::path rsrcPath = path.parent_path() / ".rsrc" / path.filename();
|
|
||||||
fs::path finfPath = path.parent_path() / ".finf" / path.filename();
|
|
||||||
|
|
||||||
fs::ifstream rsrcIn(rsrcPath);
|
|
||||||
resources.addResources(Resources(rsrcIn));
|
|
||||||
fs::ifstream finfIn(finfPath);
|
|
||||||
type = ostype(finfIn);
|
|
||||||
creator = ostype(finfIn);
|
|
||||||
fs::ifstream dataIn(path);
|
fs::ifstream dataIn(path);
|
||||||
data = std::string(std::istreambuf_iterator<char>(dataIn),
|
data = std::string(std::istreambuf_iterator<char>(dataIn),
|
||||||
std::istreambuf_iterator<char>());
|
std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
|
fs::ifstream rsrcIn(path.parent_path() / ".rsrc" / path.filename());
|
||||||
|
resources.addResources(Resources(rsrcIn));
|
||||||
|
fs::ifstream finfIn(path.parent_path() / ".finf" / path.filename());
|
||||||
|
type = ostype(finfIn);
|
||||||
|
creator = ostype(finfIn);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#ifdef __APPLE__
|
||||||
|
case Format::real:
|
||||||
|
{
|
||||||
|
fs::ifstream dataIn(path);
|
||||||
|
data = std::string(std::istreambuf_iterator<char>(dataIn),
|
||||||
|
std::istreambuf_iterator<char>());
|
||||||
|
fs::ifstream rsrcIn(path / "..namedfork" / "rsrc");
|
||||||
|
resources.addResources(Resources(rsrcIn));
|
||||||
|
|
||||||
|
char finf[32];
|
||||||
|
int n = getxattr(path.c_str(), XATTR_FINDERINFO_NAME,
|
||||||
|
finf, 32, 0, 0);
|
||||||
|
|
||||||
|
std::istringstream finfIn(std::string(finf, finf+n));
|
||||||
|
type = ostype(finfIn);
|
||||||
|
creator = ostype(finfIn);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -202,7 +219,6 @@ bool ResourceFile::write()
|
|||||||
ostype(finfOut, creator);
|
ostype(finfOut, creator);
|
||||||
for(int i = 8; i < 32; i++)
|
for(int i = 8; i < 32; i++)
|
||||||
byte(finfOut, 0);
|
byte(finfOut, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -213,7 +229,7 @@ bool ResourceFile::write()
|
|||||||
std::ostringstream finfOut;
|
std::ostringstream finfOut;
|
||||||
|
|
||||||
dataOut << data;
|
dataOut << data;
|
||||||
rsrc.writeFork(rsrcOut);
|
resources.writeFork(rsrcOut);
|
||||||
|
|
||||||
ostype(finfOut, type);
|
ostype(finfOut, type);
|
||||||
ostype(finfOut, creator);
|
ostype(finfOut, creator);
|
||||||
|
Loading…
Reference in New Issue
Block a user