Board index » cppbuilder » Re: Copying one file into another

Re: Copying one file into another


2007-11-08 08:11:37 AM
cppbuilder103
Quote
>__fastcall ~TCopyThread();
Thanks Bruce, I overlooked that.
 
 

Re:Re: Copying one file into another

"CJ" < XXXX@XXXXX.COM >wrote in message
Quote
I don't think this code likes me, just when I though I had it all
compiled.

[ILINK32 Error] Error: Unresolved external '__fastcall
TCopyThread::~TCopyThread()' referenced from
Sorry, my mistake, I was originally going to use the constructor and
destructor to manage the file handles, then decided to move them into
Execute() and DoTerminate() instead. Remove the destructor from the class
declaration.
Quote
I don't see why there is an error.
Because there is a destructor defined in the class declaration, but no body
actually implemented for it.
Gambit
 

Re:Re: Copying one file into another

Gambit, can you explain something to me in a nutshell.
I tried copying a 50MB file and it only copied 1MB, I am looking
at the code and trying to understand it. From what I see, the code
is taking one file and copying 1MB of the contents to another file.
Is that correct?
CJ
 

{smallsort}

Re:Re: Copying one file into another

"CJ" < XXXX@XXXXX.COM >wrote in message
Quote
I tried copying a 50MB file and it only copied 1MB
Then the code is still wrong. Please show exactly what you are using.
Quote
I am looking at the code and trying to understand it. From
what I see, the code is taking one file and copying 1MB of
the contents to another file. Is that correct?
It is supposed to be copying the entire file in 1MB chunks, 1 chunk per
thread. It should not be stopping after just 1 MB total.
Gambit
 

Re:Re: Copying one file into another

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote
It is supposed to be copying the entire file in 1MB chunks, 1 chunk per
thread. It should not be stopping after just 1 MB total.
I think I know what the problem is. The call to CreateFile() that is
opening the target file is not specifying the FILE_SHARE_WRITE flag, so only
one thread at a time can successfully open the file for writing.
Change this line:
hDestFile = CreateFile(FDestFile.c_str(), GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
To this instead:
hDestFile = CreateFile(FDestFile.c_str(), GENERIC_WRITE, FILE_SHARE_READ
| FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
Gambit
 

Re:Re: Copying one file into another

Quote
To this instead:

hDestFile = CreateFile(FDestFile.c_str(), GENERIC_WRITE,
FILE_SHARE_READ
| FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

Yes, that fixed the copying problem. Now I can do some debugging and figure
out
the internals of this stuff.
Thanks for all of your help
CJ