I am trying to load the newest file from a predefined place.
Usually I just overwrite the old png and when it reloads I get the newest png file, like:
main()
{
while(true)
{
reload();
delay(10);
}
}
void reload()
{
WebView_stats1.load("link.png");
}
Which was fine in the past. But now..
They want me to load the newest image set on the system, and this per radio telescope..
- the files I get are named like "subband_plot_RTA_2018_25_07_14_56_33.png"
- where RTA stands for the radio telescope I am looking at, and we have RT2/3/4/5/6/7/8/9/A/B/C/D of those
- and this time behind it is 25-Jul-2018 14:56:33
Any idea how I can accomplish this?
Load the newest image
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: Load the newest image
To get the newest file you can:
-- call the function getFileNames() to get the files stored in a directory
You can use a pattern to include only some of the files stored in the directory, e.g. the "year" to get only files for the current year.
-- call the function getFileModificationTime() to get the time when the file was changed
If you know the time when the files have been checked the last time you can also use getYoungerFiles() to get only newer files.
Then you do not have to check the modification time for all files.
If no newer file is found the file which is already in use is the current one.
Best Regards
Leopold Knipp
Senior Support Specialist
-- call the function getFileNames() to get the files stored in a directory
You can use a pattern to include only some of the files stored in the directory, e.g. the "year" to get only files for the current year.
-- call the function getFileModificationTime() to get the time when the file was changed
If you know the time when the files have been checked the last time you can also use getYoungerFiles() to get only newer files.
Then you do not have to check the modification time for all files.
If no newer file is found the file which is already in use is the current one.
Best Regards
Leopold Knipp
Senior Support Specialist