|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
Finding newest file
I am trying to point to a directory and retrieve the newest .jpg file there and pass that file to a picture widget and render it. If no file exists... passive listen. All triggered with a global, "custom3" listener.
I am only concerned with the newest file in a local directory. Seems easy. My difficulty has been trying to sort and select the newest file... The filenames also have time and date so perhaps even sorting by filename should still work. Any ideas or sample snippets will be welcomed. Peace, Wirenut |
#2
|
||||
|
||||
You could sort the list of jpg file paths using GetPathLastModifiedTime as the SortTechnique. Is that what you are looking for? If not, what part are you missing?
Or, you may need to use the java call java_io_File_lastModified as the SortTechnique -- The reason I mentioned 2 different ways to get the file date is that you will use one or the other, depending on how you are getting the list of files. The SageTV API calls dealing with getting a list of files, and info about those files, works in the context of the server. Java File calls work in terms of the context of the client. (Placeshifter & Extender clients are Remote clients, which always operate in the server's context.) - Andy
__________________
SageTV Open Source v9 is available. - Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1. - Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus - HD Extenders: A) FAQs B) URC MX-700 remote setup Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request. |
#3
|
|||
|
|||
Well, I'm very new to this programming environment. But have programming experience with C and VB... No Java, but why not take a whack at Studio.
Essentially, I would have a directory full of picture files.... say c:\programs\data\images\.... so I believe I could read the list of files into an array; CreateArray(java.lang.DirectoryListing(java.io.c:\programs\data\images\)) then sort it by file name [which is incremental by date / time] with; Sort(java.lang.Object Data,boolean Descending,java.lang.Object SortTechnique) then select the first element of the array with; GetElement(java.lang.Object Data, 1) then pass that filename to the image widget for rendering? I may be way-off the mark... I'm totally green here. Much respect, Wirenut ps Client and Server are the same local machine. Last edited by Wirenut; 02-08-2007 at 05:39 PM. |
#4
|
||||
|
||||
If you want to use Java file system calls, you'd best familiarize yourself with the Java API docs. java.io.File.listFiles() is what you're looking for.
But realize that the code you write in Studio is not Java. It has Java-like (or for that matter C-like) expression syntax, but there are some important differences. You can call out to Java, but you need to use _ instead of . for qualifying Java package and class names as per p. 141 of the Studio manual. Also note that the first element of an array is numbered 0, not 1.
__________________
-- Greg |
#5
|
|||
|
|||
Doh... yeah... 0 for the first index of the array.
Thanks GK. I actually think I've got it working now. This interface, albeit daunting, is very wide-open. Wirenut |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|