has it finished Duplicating a file yet

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

has it finished Duplicating a file yet

Post by seaniepie » Mon Feb 10, 2014 7:43 pm

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: has it finished Duplicating a file yet

Post by Simon » Mon Feb 10, 2014 9:15 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

Re: has it finished Duplicating a file yet

Post by seaniepie » Mon Feb 10, 2014 9:24 pm

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

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: has it finished Duplicating a file yet

Post by splash21 » Mon Feb 10, 2014 9:26 pm

The URL keyword is blocking - so no checking is required ;)
LiveCode Development & Training : http://splash21.com

seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

Re: has it finished Duplicating a file yet

Post by seaniepie » Mon Feb 10, 2014 10:57 pm

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.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: has it finished Duplicating a file yet

Post by jacque » Tue Feb 11, 2014 6:45 pm

You could switch to using the "load url" command, which provides a callback when the file is fully downloaded.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

Re: has it finished Duplicating a file yet

Post by seaniepie » Tue Feb 11, 2014 11:20 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: has it finished Duplicating a file yet

Post by jacque » Wed Feb 12, 2014 7:20 am

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

seaniepie
Posts: 154
Joined: Wed Sep 07, 2011 10:56 am

Re: has it finished Duplicating a file yet

Post by seaniepie » Wed Feb 12, 2014 3:59 pm

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

Post Reply