OSString * ACPIBacklightPanel::getACPIPath(IOACPIPlatformDevice * acpiDevice) { OSString * separator = OSString::withCStringNoCopy("."); OSArray * array = OSArray::withCapacity(10); char devicePath[512]; bzero(devicePath, sizeof(devicePath)); IOACPIPlatformDevice * parent = acpiDevice; IORegistryIterator * iter = IORegistryIterator::iterateOver(acpiDevice, gIOACPIPlane, kIORegistryIterateParents | kIORegistryIterateRecursively); if (iter) { do { array->setObject(parent->copyName(gIOACPIPlane)); array->setObject(separator); parent = OSDynamicCast(IOACPIPlatformDevice, iter->getNextObject()); } while (parent); iter->release(); int offset = 0; OSString * str = OSDynamicCast(OSString, array->getLastObject()); for (int i = array->getCount()-2; ((i>=0) || ((offset + str->getLength()) > sizeof(devicePath))) ; i--) { str = OSDynamicCast(OSString, array->getObject(i)); strncpy(devicePath + offset, str->getCStringNoCopy(), str->getLength()); offset += str->getLength(); } } return OSString::withCString(devicePath); }