snaggs
snaggs

Reputation: 5713

Roku BrightScript get application install date, possible?

I try t find the way to fetch application install date.

Since there is no API I thought to use Roku File System and verify create date of one of files for example under pkg:

Is it posible?

Upvotes: 1

Views: 284

Answers (3)

Alejandro Cotilla
Alejandro Cotilla

Reputation: 2621

Sorry to revive an old question, but this does not have a proper answer.

The OP was on the right track with the idea of using the roFileSystem component, no need to use the registry.

Is as simple as: buildDate = createObject("roFileSystem").Stat("pkg:/manifest").ctime

The ctime property is a roDateTime object, you can extract any date/time related info from it.

Upvotes: 2

Corgalore
Corgalore

Reputation: 2566

I keep some utility functions for that purpose:

Drop these into a Device.brs file.

function regRead(key, section=invalid)
    if section = invalid then section = "Default"
    sec = CreateObject("roRegistrySection", section)
    if sec.Exists(key) then return sec.Read(key)
    return invalid
end function

function regWrite(key, val, section=invalid)
    if section = invalid then section = "Default"
    sec = CreateObject("roRegistrySection", section)
    sec.Write(key, val)
    sec.Flush() 'commit it
end function

function regDelete(key, section=invalid)
    if section = invalid then section = "Default"
    sec = CreateObject("roRegistrySection", section)
    sec.Delete(key)
    sec.Flush()
end function

Then you can check the previous version when the channel starts up:

version = regRead("application.version")

or update the version:

regWrite("application.version", "2.5")

Upvotes: 0

Nas Banov
Nas Banov

Reputation: 29018

It is possible in a different way - use roRegistrySection. When the app starts, check if some key - say "install_date" - exists. If not, this is the first time it is started, create that key and plant the current timestamp there. Next time the app starts it will be able to determine when it was first installed from there.

Upvotes: 4

Related Questions