revCopyFile slow?

Maarten Koopmans maarten.koopmans at gmail.com
Thu Apr 14 11:16:23 EDT 2011


Actually, the below functions work pretty fast on Win7 (will test on OS X).
Added them as a back script.... works nicely. Credit where credit is due,
the fileSize function I grabbed from the mailing list (weird that such a
thing is not readily available....)

function fileSize pFilePath
   -- split the file path into the folder and url-encoded file name
   local tFolder, tEncodedFile
   set the itemDelimiter to slash
   put item 1 to -2 of pFilePath into tFolder
   put urlEncode(item -1 of pFilePath) into tEncodedFile
   set the itemDelimiter to comma
   -- now change the defaultfolder and get the detailed files information
   local tOldDefaultFolder, tDetailedFiles
   put the defaultFolder into tOldDefaultFolder
   set the defaultFolder to tFolder
   put the detailed files into tDetailedFiles
   set the defaultFolder to tOldDefaultFolder
   -- filter down the list to just the file we're interested in
   filter tDetailedFiles with (tEncodedFile & ",*")
   return (item 2 of tDetailedFiles + item 3 of tDetailedFiles)
end FileSize

on copyFile source,destination
   --revCopyFile source,destination
   put fileSize(source) into theSize
   open file source for binary read
   open file destination for binary write

   put 16384 into buflen

   repeat until  theSize is 0
      if theSize >16384 then put 16384 into buflen
      read from file source for  buflen
      write it to file destination
      subtract buflen from theSize
      put theSize into buflen
   end repeat

      close file source
      close file destination
end copyFile

On Sun, Apr 10, 2011 at 4:57 PM, Mike Bonner <bonnmike at gmail.com> wrote:

> For shell windows showing look at the property hideConsoleWindows
>
> If you're worried about shell blocking, could do your file management stuff
> as a process instead.
>
> Syntax:
> open process appName [for [text|binary] {read | write | update | neither}]
>
> Haven't done much with open process myself, but can probably do what you
> want that way.
>
> On Sun, Apr 10, 2011 at 8:49 AM, Maarten Koopmans <
> maarten.koopmans at gmail.com> wrote:
>
> > I'll try the command shell, I hope the command window doesn't show.
> > Blocking behavior is another fear ( why revCopyFile is unacceptable).
> >
> > Thanks for all the hints and advice everybody!
> >
> > --Maarten
> >
> > On Sunday, April 10, 2011, Jim Ault <jimaultwins at yahoo.com> wrote:
> > > On Apr 10, 2011, at 5:31 AM, Mark Schonewille wrote:
> > >
> > > Maarten,
> > > That depends on many factors. I have been in situations where writing a
> > few tens of thousands of files too hours using read/write, while using
> the
> > shell command took a few minutes. I have also been in situations where
> > read/write was actually the preferred method. If it is about speed,
> though,
> > I'd go with the command line. You can do the benchmarking if it really
> > matters to you.
> > >
> > >
> > > And if you program your progress bar to show
> > > movie trailers, sports highlights, or car crashes,
> > > the user won't mind so much if the file writing process is slower.
> > >
> > > Jim Ault
> > > Las Vegas
> > >
> > >
> > > On 10 apr 2011, at 14:14, Maarten Koopmans wrote:
> > >
> > >
> > > Really?  Ever benchmarked open, read, write on files? How slow are
> they?
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > use-livecode mailing list
> > > use-livecode at lists.runrev.com
> > > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > > http://lists.runrev.com/mailman/listinfo/use-livecode
> > >
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> > subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the Use-livecode mailing list