mirror of
https://github.com/jorio/Pomme.git
synced 2024-11-27 05:49:18 +00:00
Fork handle remembers the FSSpec it originated from
This commit is contained in:
parent
ffc5a80b9c
commit
3ee40824cc
@ -45,6 +45,15 @@ std::iostream& Pomme::Files::GetStream(short refNum)
|
||||
return openFiles[refNum]->GetStream();
|
||||
}
|
||||
|
||||
const FSSpec& Pomme::Files::GetSpec(short refNum)
|
||||
{
|
||||
if (!IsRefNumLegal(refNum))
|
||||
{
|
||||
throw std::runtime_error("illegal refNum");
|
||||
}
|
||||
return openFiles[refNum]->spec;
|
||||
}
|
||||
|
||||
void Pomme::Files::CloseStream(short refNum)
|
||||
{
|
||||
if (!IsRefNumLegal(refNum))
|
||||
|
@ -18,8 +18,8 @@ struct HostForkHandle : public ForkHandle
|
||||
std::fstream backingStream;
|
||||
|
||||
public:
|
||||
HostForkHandle(ForkType theForkType, char perm, fs::path& path)
|
||||
: ForkHandle(theForkType, perm)
|
||||
HostForkHandle(ForkType theForkType, char perm, fs::path& path, const FSSpec& theSpec)
|
||||
: ForkHandle(theForkType, perm, theSpec)
|
||||
{
|
||||
std::ios::openmode openmode = std::ios::binary;
|
||||
if (permission & fsWrPerm) openmode |= std::ios::out;
|
||||
@ -135,7 +135,7 @@ OSErr HostVolume::OpenFork(const FSSpec* spec, ForkType forkType, char permissio
|
||||
{
|
||||
return fnfErr;
|
||||
}
|
||||
handle = std::make_unique<HostForkHandle>(DataFork, permission, path);
|
||||
handle = std::make_unique<HostForkHandle>(DataFork, permission, path, *spec);
|
||||
return noErr;
|
||||
}
|
||||
else
|
||||
@ -173,7 +173,7 @@ OSErr HostVolume::OpenFork(const FSSpec* spec, ForkType forkType, char permissio
|
||||
continue;
|
||||
}
|
||||
path = candidatePath;
|
||||
handle = std::make_unique<HostForkHandle>(ResourceFork, permission, path);
|
||||
handle = std::make_unique<HostForkHandle>(ResourceFork, permission, path, *spec);
|
||||
if (c.isAppleDoubleFile)
|
||||
{
|
||||
ADFJumpToResourceFork(handle->GetStream());
|
||||
|
@ -15,11 +15,13 @@ namespace Pomme::Files
|
||||
public:
|
||||
ForkType forkType;
|
||||
char permission;
|
||||
FSSpec spec;
|
||||
|
||||
protected:
|
||||
ForkHandle(ForkType _forkType, char _permission)
|
||||
ForkHandle(ForkType _forkType, char _permission, const FSSpec& _spec)
|
||||
: forkType(_forkType)
|
||||
, permission(_permission)
|
||||
, spec(_spec)
|
||||
{}
|
||||
|
||||
public:
|
||||
|
@ -35,6 +35,8 @@ namespace Pomme::Files
|
||||
|
||||
std::iostream& GetStream(short refNum);
|
||||
|
||||
const FSSpec& GetSpec(short refNum);
|
||||
|
||||
void CloseStream(short refNum);
|
||||
|
||||
FSSpec HostPathToFSSpec(const fs::path& fullPath);
|
||||
|
Loading…
Reference in New Issue
Block a user