package Ġcom . dropbox . differ . resources Ċ Ċ import Ġkotlinx . c interop . address Of Ċ import Ġkotlinx . c interop . use Pin ned Ċ import Ġok io . Path . Companion . to Path Ċ import Ġplatform . Foundation . NS Bundle Ċ import Ġplatform . Foundation . NS Data Ċ import Ġplatform . Foundation . data With Contents Of File Ċ import Ġplatform . posix . memcpy Ċ Ċ actual Ġfun Ġread Resource ( path : ĠString ): ĠByteArray Ġ{ ĊĠ Ġval Ġ( filename , Ġext ) Ġ= Ġpath . to Path (). name . split (".") ĊĠ Ġval Ġresource Path Ġ= ĠNS Bundle . main Bundle . path For Resource ( ĊĠĠĠ Ġ" resources /$ filename ", ĊĠĠĠ Ġext ĊĠ Ġ) ĊĊĠ Ġval Ġdata Ġ= ĠNS Data . data With Contents Of File ( resource Path !! ) ĊĠ Ġreturn Ġdata !!. toByteArray () Ċ } Ċ Ċ internal Ġfun ĠNS Data . toByteArray (): ĠByteArray Ġ= ĠByteArray ( length . toInt ()). apply Ġ{ ĊĠ Ġuse Pin ned Ġ{ ĊĠĠĠ Ġmemcpy ( it . address Of ( 0 ), Ġbytes , Ġlength ) ĊĠ Ġ} Ċ } Ċ