Memory Problem?

Mark Schonewille m.schonewille at
Tue Feb 6 18:53:45 EST 2007

Hello Peter,

I think that 10MB is quit a big chunk of data. Have you tried smaller  
chunks as well? My experience is that smaller chunks give a smoother  
impression, while they don't slow down copying much.

I added a wait command to your code (see below).

To get and set the modification dates on Mac OS X, use AppleScript.  
To get the modification date (mind line wraps):

tell application "Finder" to set x to the modification date of file  

To set the modification date:

tell application "Finder" to set the modification date of file  
"System:Users:John:desktop:Untitled.html copy" to date "31-10-2007"

I believe that the date format needs to be the same as the system  
date if you want to write a date in abbreviated form.

AppleScript used by Revolution to copy modification dates:

on copyDate theSourceFile,theDestinationFile
   if char 1 of theSourceFile is "~" then delete char 1 of theSourceFIle
   if char 1 of theDestinationFile is "~" then delete char 1 of  
   put "tell application 'Finder'" & cr & ¬
   "set myDate to the modification date of POSIX file '/users/" &  
$USER & theSourceFile & "'" & cr & ¬
   "set the modification date of POSIX file '/users/" & $USER &  
theDestinationFile & "' to myDate" & cr & ¬
   "end tell" into myScript
   replace "'" with quote in myScript
   do myScript as AppleScript
   return the result
end copyDate

usage of the copyDate command:

copyDate "~/desktop/Untitled.html","~/desktop/Untitled.html copy"
put the result

Note that the file paths need to be absolute file paths.

Unfortunately, I expect that using AppleScript to set modification  
dates may bring you back to the original problem, which was caused by  
AppleScript locking up Revolution. A better alternative might be to  
use a shell command, but I haven't looked into that yet. There is a  
command line utility (GetFileInfo) included in Apple's developer CD,  
which may be able to do the job.




Consultancy and Software Engineering

Get your store on-line within minutes with Salery Web Store software.  
Download at

Op 6-feb-2007, om 23:24 heeft Peter Reid het volgende geschreven:

> I've now managed to use buffered file copying for the problem I  
> mentioned previously.  Here is my file copying handler:
> on copyAfile  sourceFile, destFolder, fCreatorType
>   constant cBffrSize = 10485760 -- copy in 10Mbyte chunks
>   set itemDelimiter to "/"
>   put destFolder & last item of sourceFile into destFile
>   -- set the Mac OS filetype & create destination file:
>   set the fileType to fCreatorType
>   open file destFile for binary write
>   -- open source file:
>   open file sourceFile for binary read
>   -- copy the file data:
>   put empty into dataBffr
>   put false into gotEOF
>   repeat until gotEOF
>     read from file sourceFile for cBffrSize chars
>     put the result is "eof" into gotEOF
>     put it into dataBffr
>     if dataBffr is not empty then
>       write dataBffr to file destFile
>     end if
wait 0 millisecs with messages -- increase number for more control  
over GUI
>   end repeat
>   close file destFile
>   close file sourceFile
>   -- copy Mac OS resource fork info:
>   put getResources(sourceFile) into resourceList
>   set itemDelimiter to comma
>   repeat for each line i in resourceList
>     put item 1 of i into resType
>     put item 2 of i into resID
>     put copyresource(sourceFile,destFile,resType,resID) into junk
wait 0 millisecs with messages -- increase number for more control  
over GUI
>   end repeat
>   put empty into junk
> end copyAfile
> The remaining problem I have is that the copied file has the  
> current time & date NOT the same time & date as the original file.   
> If I had used the revCopyFile, then the time & date would have been  
> preserved.
> Can anyone suggest how I can change the (creation or modified) time  
> & date on a file so the copies are the same as the originals?

More information about the Use-livecode mailing list