Total Pageviews

Saturday, April 5, 2014

ចំណែកមួយនេះជា ResourceDirectory

System.ResourceDirectory គេប្រើវាជាមួយនឹង system.pathForFile() ក្នុងការបង្កើត path មួយសំរាប់ទាញយកទិន្នន័យ នៅពេលដែលគ្រប់ទាំង application assets exits (image & sound) វាត្រូវបានហៅវា App Bundle ។ សូមកុំបង្កើត modify or add file to this directory។ ពីព្រោះការធ្វើ ដូចនេះមានន័យថា ការពារកុំឪ្យ device from verifying the integrity របស់កម្មវិធី។ ក្នុងករណីខ្លះ device នឹង treat app ជា malware ហើយមិនដំណើរការ។ សំរាប់ Property នេះអាចប្រើជាមួយ នឹង ApI ផ្សេងៗទៀតក្នុងការសំណូមពរ “base directory” ជា Parameter (display.newImage(), media.playSound(), etc) សំរាប់ resource directory ជា Default។ ចំណែកនៅក្នុង Corona វាស្ថិតនៅ sandboxed folder

Syntax: system.ResourceDirectory

សូមមើលកូដះ
local path = system.pathForFile( "data.txt", system.ResourceDirectory )
local file = io.open( path, "r" )
if file then    -- nil if no file found
    local contents = file:read( "*a" )
    print( "Contents of " .. path .. "\n" .. contents )
    io.close( file )

end

No comments:

Post a Comment