Quick wxFSFile & GetModificationTime() Question Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Ksmith22
I live to help wx-kind
I live to help wx-kind
Posts: 199
Joined: Mon Nov 21, 2005 4:34 pm

Quick wxFSFile & GetModificationTime() Question

Post by Ksmith22 » Mon Apr 03, 2006 6:43 pm

Before I mess around with this, I figured I would ask to save myself some trial-and-error. I am currently using wxFileSystem to get a file off a website. What I need to do is check when this file was last modified, and if it was changed, re-download it.

My question is, if I setup the wxFSFile once with the URL, does that just copy the contents of the file to the wxFSFile, or is it a pointer to that location? In other words, if I called GetModificationTime() several times and nothing else, would it always return the same time even if the file had been modified on the website? Here's some code to illustrate:

Code: Select all

wxString url = "http://www.somewebsite.com/somefile.txt";

wxFileSystem fileurl;
wxFSFile* fsfile = fileurl.OpenFile(url);

wxDateTime start_time = fsfile->GetModificationTime();

// wait some time.. file from URL has now changed

wxDateTime current_time = fsfile->GetModificationTime();
With that code, are start_time and current_time the same? Or do I need to re-call "fsfile = fileurl.OpenFile(url)" first?

micros
Super wx Problem Solver
Super wx Problem Solver
Posts: 317
Joined: Sat Mar 18, 2006 10:41 am
Location: Ustek, Bohemia

Post by micros » Tue Apr 04, 2006 8:16 am

Looking at wxInternetFSHandler::OpenFile (src/common/fs_inet.cpp), I'd answer your question "Yes, the times are the same". The handler not only opens the remote file, it copies it to a temporary local file and returns a wxFSFile of the local one.

Ksmith22
I live to help wx-kind
I live to help wx-kind
Posts: 199
Joined: Mon Nov 21, 2005 4:34 pm

Post by Ksmith22 » Tue Apr 04, 2006 1:52 pm

micros wrote:Looking at wxInternetFSHandler::OpenFile (src/common/fs_inet.cpp), I'd answer your question "Yes, the times are the same". The handler not only opens the remote file, it copies it to a temporary local file and returns a wxFSFile of the local one.
Gotcha. Thanks!

Post Reply