Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
guidamedia2
Visitor

dynamic file path

Is there an issue using variables in a path, as such?

theme.OverhangPrimaryLogoHD = "pkg:/images/" + image_dir + "/Logo_Overhang_HD.png"

not getting any images to show.
0 Kudos
9 REPLIES 9
guidamedia2
Visitor

Re: dynamic file path

Does anyone have a clue on this? I have several channels to manage, and I am trying to streamline the process.

I am storing all the images into subfolders in the images dir. Each subfolder hold different files for the different channels.
0 Kudos
BugLaden
Visitor

Re: dynamic file path

Looks like that should work. Just checked the reference, and + can be used to join strings. My only suggestion is find out if the OS is case-sensitive on files, and if so, make sure the case of the [directory] names match your string.
0 Kudos
guidamedia2
Visitor

Re: dynamic file path

Roku is case insensitive, but the files to match.

What about using integers for directories? Does anyone know if Roku allows this?

All I did was move my files from /images to different subfolders: images/0, images/23 and images/113, where each one has a few different files.

Once I did that, my channel stopped showing the images.

When I reverted back, but still have no images.
0 Kudos
RokuMarkn
Visitor

Re: dynamic file path

Your code looks fine. You can print theme.OverhangPrimaryLogoHD to verify that it's what you think it is.
The fact that you still have no images after reverting indicates that you may have made an accidental change somewhere else that is breaking things. If you're using a source code control system (as everyone should), revert to a known working version and start again from there.

--Mark
0 Kudos
guidamedia2
Visitor

Re: dynamic file path

Yes, using CVS.

The code is only in one place, and I am printing out temp. The paths look right, and when I copy and paste them into windows explorer, the image is found.

I had reorganized my several projects into one master, which included moving the images. Once I did this, the images stopped working.

I reverted back, but no luck.

This is very simple, and the paths are very simple. I am using the following code to debug:


image_dir = dChannelManifestGet("theater_id")'gets the theater id (string) from the manifest file
mypath = CreateObject("roFileSystem")
if mypath.Exists("pkg:/images/" + image_dir + "/image.png") then
fDbg("pkg:/images/" + image_dir + "/image.png IS VALID")
else
fDbg("pkg:/images/" + image_dir + "/image.png IS NOT VALID")
end if

Result
pkg:/images/0/hm_hd.png IS NOT VALID
0 Kudos
guidamedia2
Visitor

Re: dynamic file path

Actually I am using this debug code, and everything is returning false


mypath = CreateObject("roFileSystem")
if mypath.Exists("pkg:/images/") = true then
fDbg("pkg:/images/ IS VALID")
else
fDbg("pkg:/images/ IS NOT VALID")
end if

Result
pkg:/images/ IS NOT VALID
0 Kudos
guidamedia2
Visitor

Re: dynamic file path

I finally figured it out.

First, I am using Version 3.1, and what I have found that if you have a sub-directory within the images folder and that sub-directory has any image file in it, regardless if it is being used by the channel or not, no images will show. :shock:
At first I thought it was because the naming conventions were the same, but when I tried changing the name, still the channel displayed no images. So I removed the images from the sub-folder, and the channel displayed the images. I then added a text file, and it did display the images. Finally, I added a GIF image, and no images appeared.

:idea: My solution for 3.1 is, multiple image folders at the root level. So rather then have pkg:/images/{id}/file.png, I am setting it up so it is pkg:/images_{id}/file.png, which for me actually works better. It does rub my compulsion for organization and structure the wrong way, but now I can have a default folder pkg:/images/, and if a theater id is not found it does not add "_{id}" to the images directory name.

I am going to test on my 4.2 roku box and see if it handles it just fine.
0 Kudos
BugLaden
Visitor

Re: dynamic file path

That's really strange. There are several examples in the 4.8 SDK that use paths deeper than 1 level for the images. Look at a the clock program. There are images in the images directory and in the sub-directories. So if it's not working in 3.1, then most likely this type of access to the image directory is different. Wonder when this deep directory access for images was implemented?
0 Kudos
TheEndless
Channel Surfer

Re: dynamic file path

"BugLaden" wrote:
That's really strange. There are several examples in the 4.8 SDK that use paths deeper than 1 level for the images. Look at a the clock program. There are images in the images directory and in the sub-directories. So if it's not working in 3.1, then most likely this type of access to the image directory is different. Wonder when this deep directory access for images was implemented?

There's no such restriction that I'm aware of. I have several channels and screensavers that use deeper image paths.
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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.