mirror of
https://github.com/autc04/Retro68.git
synced 2025-02-27 20:30:31 +00:00
ResourceFiles: read-only AppleDouble support (._filename convention)
This commit is contained in:
parent
d55bee477e
commit
3c4350b435
@ -142,7 +142,24 @@ bool ResourceFile::assign(std::string pathstring, ResourceFile::Format f)
|
|||||||
format = Format::diskimage;
|
format = Format::diskimage;
|
||||||
//else if(fs::exists(rsrcPath))
|
//else if(fs::exists(rsrcPath))
|
||||||
// format = Format::basilisk;
|
// format = Format::basilisk;
|
||||||
else
|
}
|
||||||
|
if(format == Format::autodetect)
|
||||||
|
{
|
||||||
|
fs::path adPath = path.parent_path() / ("._" + path.filename().string());
|
||||||
|
fs::ifstream in(adPath);
|
||||||
|
if(in)
|
||||||
|
{
|
||||||
|
int magic1 = longword(in);
|
||||||
|
|
||||||
|
if(in && magic1 == 0x00051607)
|
||||||
|
{
|
||||||
|
int magic2 = longword(in);
|
||||||
|
if(in && magic2 == 0x00020000)
|
||||||
|
format = Format::underscore_appledouble;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(format == Format::autodetect)
|
||||||
{
|
{
|
||||||
fs::ifstream in(path);
|
fs::ifstream in(path);
|
||||||
if(in)
|
if(in)
|
||||||
@ -156,7 +173,6 @@ bool ResourceFile::assign(std::string pathstring, ResourceFile::Format f)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(format == Format::autodetect)
|
if(format == Format::autodetect)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@ -186,9 +202,12 @@ bool ResourceFile::read()
|
|||||||
fs::ifstream rsrcIn(path.parent_path() / ".rsrc" / path.filename());
|
fs::ifstream rsrcIn(path.parent_path() / ".rsrc" / path.filename());
|
||||||
resources = Resources(rsrcIn);
|
resources = Resources(rsrcIn);
|
||||||
fs::ifstream finfIn(path.parent_path() / ".finf" / path.filename());
|
fs::ifstream finfIn(path.parent_path() / ".finf" / path.filename());
|
||||||
|
if(finfIn)
|
||||||
|
{
|
||||||
type = ostype(finfIn);
|
type = ostype(finfIn);
|
||||||
creator = ostype(finfIn);
|
creator = ostype(finfIn);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
case Format::real:
|
case Format::real:
|
||||||
@ -231,6 +250,7 @@ bool ResourceFile::read()
|
|||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
// ###
|
// ###
|
||||||
|
// FIXME: read data fork
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
resources = Resources(in);
|
resources = Resources(in);
|
||||||
@ -243,6 +263,40 @@ bool ResourceFile::read()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Format::underscore_appledouble:
|
||||||
|
{
|
||||||
|
fs::ifstream dataIn(path);
|
||||||
|
data = std::string(std::istreambuf_iterator<char>(dataIn),
|
||||||
|
std::istreambuf_iterator<char>());
|
||||||
|
|
||||||
|
fs::path adPath = path.parent_path() / ("._" + path.filename().string());
|
||||||
|
fs::ifstream in(adPath);
|
||||||
|
if(longword(in) != 0x00051607)
|
||||||
|
return false;
|
||||||
|
if(longword(in) != 0x00020000)
|
||||||
|
return false;
|
||||||
|
in.seekg(24);
|
||||||
|
int n = word(in);
|
||||||
|
for(int i = 0; i < n; i++)
|
||||||
|
{
|
||||||
|
in.seekg(26 + i * 12);
|
||||||
|
int what = longword(in);
|
||||||
|
int off = longword(in);
|
||||||
|
//int len = longword(in);
|
||||||
|
in.seekg(off);
|
||||||
|
switch(what)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
resources = Resources(in);
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
type = ostype(in);
|
||||||
|
creator = ostype(in);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case Format::macbin:
|
case Format::macbin:
|
||||||
{
|
{
|
||||||
fs::ifstream in(path);
|
fs::ifstream in(path);
|
||||||
@ -263,6 +317,7 @@ bool ResourceFile::read()
|
|||||||
unsigned short crc = CalculateCRC(0,header,124);
|
unsigned short crc = CalculateCRC(0,header,124);
|
||||||
if(word(in) != crc)
|
if(word(in) != crc)
|
||||||
return false;
|
return false;
|
||||||
|
// FIXME: read data fork
|
||||||
in.seekg(128 + datasize);
|
in.seekg(128 + datasize);
|
||||||
resources = Resources(in);
|
resources = Resources(in);
|
||||||
}
|
}
|
||||||
@ -354,6 +409,9 @@ bool ResourceFile::write()
|
|||||||
longword(out, 32);
|
longword(out, 32);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// TODO: case Format::underscore_appledouble
|
||||||
|
|
||||||
case Format::diskimage:
|
case Format::diskimage:
|
||||||
{
|
{
|
||||||
std::ostringstream rsrcOut;
|
std::ostringstream rsrcOut;
|
||||||
|
@ -18,7 +18,7 @@ public:
|
|||||||
diskimage,
|
diskimage,
|
||||||
basilisk,
|
basilisk,
|
||||||
applesingle,
|
applesingle,
|
||||||
//underscore_ad,
|
underscore_appledouble,
|
||||||
//appledouble
|
//appledouble
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user