File copy progress indicator

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

File copy progress indicator

Postby John Clapperton » Mon Oct 20, 2008 5:59 am

Hi,

Does anyone know how to display a progress indicator (like Windows Explorer does) when invoking Win32 file copy via CfsFileDescriptor class>>copy:new: ?

tia,
John
John Clapperton
[|]
 
Posts: 18
Joined: Wed Oct 03, 2007 6:21 am

Re: File copy progress indicator

Postby Ralf » Mon Oct 20, 2008 7:49 am

with a new method can you implement this behavior. At the moment copy:new: will use the Win API function CopyFileA, create a new method and use the Win API function CopFileEx. You can give a Callback method to CopyFileEx, CopyFileEx will call this function and you can implement a progressbar or what ever. Sorry, I have not create a method, I think it's more or less "simple".

At the other side, maybe is a good old byte for byte copy routine implemented an alternative.:)

For mor information for CopyFileEx and CopyProgressRoutine look at Win API Reference.

BOOL CopyFileEx(

LPCWSTR lpExistingFileName, // pointer to name of an existing file
LPCWSTR lpNewFileName, // pointer to filename to copy to
LPPROGRESS_ROUTINE lpProgressRoutine, // pointer to the callback function
LPVOID lpData, // to be passed to the callback function
LPBOOL pbCancel, // flag that can be used to cancel the operation
DWORD dwCopyFlags // flags that specify how the file is copied
);

DWORD WINAPI CopyProgressRoutine(

LARGE_INTEGER TotalFileSize, // total file size, in bytes
LARGE_INTEGER TotalBytesTransferred, // total number of bytes transferred
LARGE_INTEGER StreamSize, // total number of bytes for this stream
LARGE_INTEGER StreamBytesTransferred, // total number of bytes transferred for this stream
DWORD dwStreamNumber, // the current stream
DWORD dwCallbackReason, // reason for callback
HANDLE hSourceFile, // handle to the source file
HANDLE hDestinationFile, // handle to the destination file
LPVOID lpData // passed by CopyFileEx
);
Ralf
 
Posts: 41
Joined: Thu Nov 16, 2006 4:18 am

Re: File copy progress indicator

Postby marten » Mon Oct 20, 2008 8:03 am

John Clapperton wrote:Hi,

Does anyone know how to display a progress indicator (like Windows Explorer does) when invoking Win32 file copy via CfsFileDescriptor class>>copy:new: ?

tia,
John


Within my MSKKernel I've implemented several Smalltalk codes to copy files/directories (only using Smalltalk code) with or without GUI including a progress dialog - with rollback control. Perhaps this might be interested.
Marten Feldtmann, Principal Smalltalk User, Private
SkypeMe callto://marten.feldtmann
marten
[|]
 
Posts: 641
Joined: Sat Oct 14, 2006 7:10 am
Location: Hamburg - Germany


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest