Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
YungBlood
Level 7

Check if File Exists?

Hi,
Is it possible to check to see if a file exists easily?

I would like to check to see if I've downloaded a file into tmp:/... and use it if it exists, rather than than just downloading it each time.
-Kevin
YungBlood

Bringing more fun to Roku!
0 Kudos
3 Replies
renojim
Level 9

Re: Check if File Exists?

    x = MatchFiles("tmp:/",filename)
if x.Count() = 0 then FILE DOES NOT EXIST


-JT
0 Kudos
TheEndless
Level 7

Re: Check if File Exists?

Or optionally...
fs = CreateObject( "roFileSystem" )
If fs.Exists( "tmp:/myfile") Then
'found it
End If
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
YungBlood
Level 7

Re: Check if File Exists?

Thanks! Smiley Happy
They both work. Though each one has it's advantages... I'm using the fs version since I don't want to parse the filename. Smiley Happy

I'm starting to collect utility routines that roku is missing... I'll post them on my website later. Here's how I tried both styles


Function FileExists(file as String) as Integer
last = 0
l = len(file)
for x = 1 to l
r = instr(x, file, "/")
if r > last then last = r
if r = 0 then exit for
end for
path = left(file, last)
filename = right(file, l - last)
return MatchFiles(path, filename).Count()
end function


Function FileExists(file as String) as Integer
fs = CreateObject("roFileSystem")
If fs.Exists(file) Then
return 1
End If
return 0
end function
YungBlood

Bringing more fun to Roku!
0 Kudos