mirror of
https://github.com/jorio/Pomme.git
synced 2025-01-13 12:31:44 +00:00
New file routines: GetVol, FSOpen, OpenResFile, ChangedResource
This commit is contained in:
parent
3228cf2818
commit
2f57b5245e
@ -151,6 +151,13 @@ OSErr FSpOpenRF(const FSSpec* spec, char permission, short* refNum)
|
||||
return OpenFork(spec, ForkType::ResourceFork, permission, refNum);
|
||||
}
|
||||
|
||||
OSErr FSOpen(const char* cName, short vRefNum, short* refNum)
|
||||
{
|
||||
FSSpec spec;
|
||||
FSMakeFSSpec(vRefNum, 0, cName, &spec);
|
||||
return FSpOpenDF(&spec, fsRdPerm, refNum);
|
||||
}
|
||||
|
||||
OSErr FindFolder(short vRefNum, OSType folderType, Boolean createFolder, short* foundVRefNum, long* foundDirID)
|
||||
{
|
||||
if (vRefNum != kOnSystemDisk)
|
||||
@ -283,6 +290,15 @@ OSErr ResolveAlias(const FSSpec* spec, AliasHandle alias, FSSpec* target, Boolea
|
||||
return FSMakeFSSpec(spec->vRefNum, spec->parID, targetFilename.c_str(), target);
|
||||
}
|
||||
|
||||
OSErr GetVol(char* outVolNameC, short* vRefNum)
|
||||
{
|
||||
if (vRefNum)
|
||||
*vRefNum = 0;
|
||||
if (outVolNameC)
|
||||
*outVolNameC = '\0';
|
||||
return nsvErr;
|
||||
}
|
||||
|
||||
OSErr FSRead(short refNum, long* count, Ptr buffPtr)
|
||||
{
|
||||
if (*count < 0) return paramErr;
|
||||
|
@ -70,7 +70,7 @@ long HostVolume::GetDirectoryID(const fs::path& dirPath)
|
||||
|
||||
fs::path HostVolume::ToPath(long parID, const std::string& name)
|
||||
{
|
||||
fs::path path = directories[parID] / AsU8(name);
|
||||
fs::path path = directories.at(parID) / AsU8(name);
|
||||
return path.lexically_normal();
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ OSErr HostVolume::FSMakeFSSpec(long dirID, const std::string& fileName, FSSpec*
|
||||
throw std::runtime_error("HostVolume::FSMakeFSSpec: directory ID not registered.");
|
||||
}
|
||||
|
||||
auto path = directories[dirID];
|
||||
auto path = directories.at(dirID);
|
||||
auto suffix = fileName;
|
||||
|
||||
// Case-insensitive sanitization
|
||||
|
@ -207,6 +207,13 @@ short FSpOpenResFile(const FSSpec* spec, char permission)
|
||||
return slot;
|
||||
}
|
||||
|
||||
short OpenResFile(const char* cName)
|
||||
{
|
||||
FSSpec spec;
|
||||
FSMakeFSSpec(0, 0, cName, &spec);
|
||||
return FSpOpenResFile(&spec, fsRdPerm);
|
||||
}
|
||||
|
||||
void UseResFile(short refNum)
|
||||
{
|
||||
// See MoreMacintoshToolbox:1-69
|
||||
@ -315,6 +322,11 @@ void AddResource(Handle theData, ResType theType, short theID, const char* name)
|
||||
TODO();
|
||||
}
|
||||
|
||||
void ChangedResource(Handle theResource)
|
||||
{
|
||||
TODO();
|
||||
}
|
||||
|
||||
void WriteResource(Handle theResource)
|
||||
{
|
||||
TODO();
|
||||
|
16
src/Pomme.h
16
src/Pomme.h
@ -29,7 +29,7 @@ extern "C"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// FSSpec
|
||||
// File/volume management
|
||||
|
||||
OSErr FSMakeFSSpec(short vRefNum, long dirID, const char* cstrFileName, FSSpec* spec);
|
||||
|
||||
@ -41,6 +41,16 @@ OSErr FSpOpenDF(const FSSpec* spec, char permission, short* refNum);
|
||||
// Open a file's resource fork
|
||||
OSErr FSpOpenRF(const FSSpec* spec, char permission, short* refNum);
|
||||
|
||||
// Open a file's data fork with fsRdPerm (TODO: it should be fsCurPerm, but we don't support fsCurPerm yet)
|
||||
// in directory 0 of the given volume. It is legal to pass in a colon-separated hierarchical path in cName.
|
||||
// (Note: this is an ancient function that predates HFS - IM vol II, 1985)
|
||||
OSErr FSOpen(const char* cName, short vRefNum, short* refNum);
|
||||
|
||||
// Open a file's resource fork with fsRdPerm (TODO: it should be fsCurPerm, but we don't support fsCurPerm yet)
|
||||
// in directory 0 of the application's volume. It is legal to pass in a colon-separated hierarchical path in cName.
|
||||
// (Note: this is an ancient function that predates HFS - IM vol II, 1985)
|
||||
short OpenResFile(const char* cName);
|
||||
|
||||
OSErr FSpCreate(const FSSpec* spec, OSType creator, OSType fileType, ScriptCode scriptTag);
|
||||
|
||||
OSErr FSpDelete(const FSSpec* spec);
|
||||
@ -51,6 +61,8 @@ OSErr FindFolder(short vRefNum, OSType folderType, Boolean createFolder, short*
|
||||
|
||||
OSErr DirCreate(short vRefNum, long parentDirID, const char* cstrDirectoryName, long* createdDirID);
|
||||
|
||||
OSErr GetVol(char* outVolNameC, short* vRefNum);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// File I/O
|
||||
|
||||
@ -93,6 +105,8 @@ void RemoveResource(Handle theResource);
|
||||
|
||||
void AddResource(Handle theData, ResType theType, short theID, const char* name);
|
||||
|
||||
void ChangedResource(Handle theResource);
|
||||
|
||||
void WriteResource(Handle theResource);
|
||||
|
||||
void DetachResource(Handle theResource);
|
||||
|
Loading…
x
Reference in New Issue
Block a user