Forum Discussion

guidamedia2's avatar
13 years ago

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.

9 Replies

  • 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.
  • 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.
  • 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.
  • 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
  • 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
  • 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
  • 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.
  • 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?
  • "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.