mirror of
https://github.com/ksherlock/mpw.git
synced 2025-01-01 21:29:20 +00:00
clean up some other RM code
This commit is contained in:
parent
6197910e3e
commit
3ff0697e46
@ -890,24 +890,19 @@ namespace RM
|
|||||||
|
|
||||||
|
|
||||||
Handle nativeHandle = NULL;
|
Handle nativeHandle = NULL;
|
||||||
if (theData)
|
|
||||||
{
|
|
||||||
uint32_t handleSize;
|
|
||||||
MM::Native::GetHandleSize(theData, handleSize);
|
|
||||||
|
|
||||||
if (handleSize)
|
auto info = MM::GetHandleInfo(theData);
|
||||||
{
|
if (info.error()) return SetResError(MacOS::addResFailed);
|
||||||
|
|
||||||
nativeHandle = ::NewHandle(handleSize);
|
|
||||||
if (!nativeHandle) return SetResError(MacOS::addResFailed);
|
|
||||||
|
|
||||||
uint32_t src = memoryReadLong(theData);
|
nativeHandle = ::NewHandle(info->size);
|
||||||
|
if (!nativeHandle) return SetResError(MacOS::addResFailed);
|
||||||
|
|
||||||
std::memcpy(*(uint8_t **)nativeHandle, memoryPointer(src), handleSize);
|
|
||||||
|
|
||||||
rhandle_map.insert({theData, nativeHandle});
|
std::memcpy(*(uint8_t **)nativeHandle, memoryPointer(info->address), info->size);
|
||||||
}
|
|
||||||
}
|
rhandle_map.insert({theData, nativeHandle});
|
||||||
|
|
||||||
// AddResource assumes ownership of the handle.
|
// AddResource assumes ownership of the handle.
|
||||||
::AddResource(nativeHandle, theType, theID, memoryPointer(namePtr));
|
::AddResource(nativeHandle, theType, theID, memoryPointer(namePtr));
|
||||||
return SetResError(::ResError());
|
return SetResError(::ResError());
|
||||||
@ -1147,10 +1142,9 @@ namespace RM
|
|||||||
|
|
||||||
|
|
||||||
// if it has a size, it's loaded...
|
// if it has a size, it's loaded...
|
||||||
uint32_t handleSize;
|
auto info = MM::GetHandleInfo(theResource);
|
||||||
err = MM::Native::GetHandleSize(theResource, handleSize);
|
if (info.error()) return SetResError(resNotFound);
|
||||||
if (err) return SetResError(err);
|
if (info->size) return SetResError(0);
|
||||||
if (handleSize) return SetResError(0);
|
|
||||||
|
|
||||||
// otherwise, load it
|
// otherwise, load it
|
||||||
|
|
||||||
@ -1162,7 +1156,7 @@ namespace RM
|
|||||||
|
|
||||||
::LoadResource(nativeHandle);
|
::LoadResource(nativeHandle);
|
||||||
err = ::ResError();
|
err = ::ResError();
|
||||||
if (err) return SetResError(err); // ?!?!
|
if (err) return SetResError(err);
|
||||||
|
|
||||||
|
|
||||||
size = ::GetHandleSize(nativeHandle);
|
size = ::GetHandleSize(nativeHandle);
|
||||||
@ -1174,8 +1168,9 @@ namespace RM
|
|||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
{
|
{
|
||||||
uint32_t ptr = memoryReadLong(theResource);
|
info = MM::GetHandleInfo(theResource);
|
||||||
std::memcpy(memoryPointer(ptr), *(void **)nativeHandle, size);
|
|
||||||
|
std::memcpy(memoryPointer(info->address), *(void **)nativeHandle, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SetResError(0);
|
return SetResError(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user