Page 1 of 1

has it finished Duplicating a file yet

Posted: Mon Feb 10, 2014 7:43 pm
by seaniepie
Hi all,
If I were to do this:
put url("binfile:defaultLogo.png") into url("binfile:logo.png")
How do I know when it's finished? So that I don't call a "set the filename of img "myPic" to "logo.png"" too soon

Thanks

Re: has it finished Duplicating a file yet

Posted: Mon Feb 10, 2014 9:15 pm
by Simon
An "if there is a file" loop?

Code: Select all

repeat forever
if there is a file "logo.png" then
set the fileName of img 1 to "logo.png"
exit repeat
end if
end repeat
Simon

Re: has it finished Duplicating a file yet

Posted: Mon Feb 10, 2014 9:24 pm
by seaniepie
Hi Simon
Thanks for the idea. That's what I would have thought too but apparently, on a Mac anyway, it creates the file then starts putting the data into it. So as far as LC/standalone is concerned the file exists as soon as you start the copy, not just once it's finished.

Does anyone have any other ideas

Thanks

Re: has it finished Duplicating a file yet

Posted: Mon Feb 10, 2014 9:26 pm
by splash21
The URL keyword is blocking - so no checking is required ;)

Re: has it finished Duplicating a file yet

Posted: Mon Feb 10, 2014 10:57 pm
by seaniepie
Hi Monte,
Thanks for your response. I would have thought that too. However there then appears to be something else wrong, as when I set the filename it displays nothing the first time. If I leave it for a bit though it displays just fine. If URL is indeed 'blocking' then why would that happen? It's puzzling.

Re: has it finished Duplicating a file yet

Posted: Tue Feb 11, 2014 6:45 pm
by jacque
You could switch to using the "load url" command, which provides a callback when the file is fully downloaded.

Re: has it finished Duplicating a file yet

Posted: Tue Feb 11, 2014 11:20 pm
by seaniepie
Hi Jacque
Great to hear your input. Unfortunately though 'load URL' only works with http and FTP but not for binfile: or file: which sucks a little. I understand why though, they're completely different protocols based around smb. So still no resolution on this one at the moment.
Anyone able to come up with something else. I'm still baffled.
Thanks all

Re: has it finished Duplicating a file yet

Posted: Wed Feb 12, 2014 7:20 am
by jacque
Right, sorry, I didn't notice you were getting files from the drive. Oops.

The only other thing I can think of is to check the file length repeatedly until it stops changing. But that's pretty wasteful.

Edit: Oh wait, have you tried the open file/read file/close file method? Reading the file until eof should block.

Re: has it finished Duplicating a file yet

Posted: Wed Feb 12, 2014 3:59 pm
by seaniepie
Edit: Oh wait, have you tried the open file/read file/close file method? Reading the file until eof should block.
Oooh, thought we had it then. But it has got me to a solution. The problem here is that while 'read from file' will block till EOF, 'write to file' doesn't necessarily. And you have no idea on progress.

However, what I found following the train of thought was to use libURLSetStatusCallback and URLStatus on desktops and urlProgress on mobiles. It seems this is not limited to http and ftp and we get a lot of feedback. It's a lot of involved work but it should work. I will post back here my findings good or bad.

Thanks all for getting me back to sanity.

Pi