|
From: Per W. <pw...@ia...> - 2005-05-17 23:30:34
|
That is your problem.
You simply can not use strcat to concatenate a "\0" since it breaks at the
\0 in the string.
p = SrcPath;
strcpy(p,LP4);
p += strlen(p)+1; // skip # of inserted chars + the '\0';
strcpy(p,SFA);
p += strlen(p)+1; // "-
strcpy(p,""); // just writes the final '\0'
And of course, you can not use std::cout to emit a char* or char[] that
contains '\0' in the middle...
/Per W
On Tue, 17 May 2005, Guillermo Gutierrez wrote:
> I am using a char SrcPath[20000] variable to hold the name (yes, the full string gets close to being that long.)
>
> I fill the array like this:
>
> //LP4 is a variable that holds the source path + filename (lp4.exe)
> //SFA - (same as above, source path + "mssfa.exe")
>
> strcpy ( SrcPath, LP4 );
> strcat ( SrcPath, "\0");
> strcat ( SrcPath, SFA );
> strcat ( SrcPath, "\0\0" );
> std::cout << "SrcPath: " << SrcPath << endl;
>
> unfortunately the output of "cout << SrcPath" shows both of the paths as one that is what is causing the app to think of it as one huge path for a file rather than 2 paths/files.
>
> -----Original Message-----
> From: Per Westermark [mailto:pw...@ia...]
> Sent: Tuesday, May 17, 2005 3:56 PM
> To: Guillermo Gutierrez
> Subject: RE: FW: [Dev-C++] Win32 Shell API
>
>
> When not generating the strings, it's almost the same thing to do:
> char *source = "hello world";
> or:
> char source[] = "hello world";
>
> When dyanmically generating the file names, then source is of course
> declared something like:
> char source[2000];
>
> Note that when concatenating multiple file names, you must manually insert
> the '\0' character after the names, since the string functions will break
> at the null character.
>
> By the way - why did you unlink the mailing list?
>
> /Per W
>
> On Tue, 17 May 2005, Guillermo Gutierrez wrote:
>
> > hmm...char *source;
> > do get a different result if you use "char source" vs "char *source"?
> >
> > -----Original Message-----
> > From: Per Westermark [mailto:pw...@ia...]
> > Sent: Tuesday, May 17, 2005 3:31 PM
> > To: Guillermo Gutierrez
> > Subject: RE: FW: [Dev-C++] Win32 Shell API
> >
> >
> > Minimalistic multi-source -> single directory:
> > char *source =
> > "c:/usr/src/test/test_shfileoperation/src/1.txt\0"
> > "c:/usr/src/test/test_shfileoperation/src/2.txt\0"
> > "c:/usr/src/test/test_shfileoperation/src/3.txt\0";
> > char *dst =
> > "c:/usr/src/test/test_shfileoperation/dst\0";
> > SHFILEOPSTRUCT op;
> > memset(&op,0,sizeof(op));
> > op.wFunc = FO_COPY;
> > op.pFrom = source;
> > op.pTo = dst;
> > int res = SHFileOperation(&op);
> >
> > (alas hand-copied from Win machine...)
> >
> > /Per W
> >
> > On Tue, 17 May 2005, Guillermo Gutierrez wrote:
> >
> > > I copy to a single destination path.
> > >
> > > -----Original Message-----
> > > From: Per Westermark [mailto:pw...@ia...]
> > > Sent: Tuesday, May 17, 2005 3:08 PM
> > > To: Guillermo Gutierrez
> > > Subject: Re: FW: [Dev-C++] Win32 Shell API
> > >
> > >
> > > Do you copy to a single destination path, or do you specify multiple
> > > destinations, i.e. one destination for every source file?
> > >
> > > /Per W
> > >
> > > On Tue, 17 May 2005, Guillermo Gutierrez wrote:
> > >
> > > > P.S.S
> > > > correction on the error:
> > > > windows tells me that it cannot read the files from the source or disk. When I click past the initial error, my custom error handling message box reveals that the function failed with an error code of '6'.
> > > > This works correctly if I only try to copy one file.
> > > >
> > > > Also, the last part of the path name is generated from the current system date by the program that creates the folder (Borland's Final Builder), so I have to do some grunt work to get the correct "full" path.
> > > >
> > > > -----Original Message-----
> > > > From: Guillermo Gutierrez
> > > > Sent: Tuesday, May 17, 2005 2:22 PM
> > > > To: 'pw...@ia...'
> > > > Subject: RE: [Dev-C++] Win32 Shell API
> > > >
> > > >
> > > > P.S.
> > > > The path string that I am copying to is quite shorter than the string that I am copying from.
> > > >
> > > > -----Original Message-----
> > > > From: Guillermo Gutierrez
> > > > Sent: Tuesday, May 17, 2005 2:19 PM
> > > > To: 'Per Westermark'
> > > > Subject: RE: [Dev-C++] Win32 Shell API
> > > >
> > > >
> > > > I am not able to get the file copy to work because it appears that for some reason the "\0" at the end of each path\filename is not being read or the path is too long.
> > > >
> > > > The path string I am using to copy from is "Q:\\QA\\Builds\\Current\\"2005-5-17\\".
> > > >
> > > > The only thing that changes is the filename that is added at the end of the string, I then use the different versions (meaning same string with different filename appended) with a null-termination ("\0") at the end to create one long string of the 10 files I need to copy. I also make sure to add an extra "\0" at the end of the whole string per the documentation (that string should be double nul-terminated).
> > > >
> > > > I get a windows error when the copy function is used stating that the file could not be found and it displays the string as one huge filename.
> > > >
> > > > -----Original Message-----
> > > > From: Per Westermark [mailto:pw...@ia...]
> > > > Sent: Tuesday, May 17, 2005 12:52 PM
> > > > To: Guillermo Gutierrez
> > > > Subject: RE: [Dev-C++] Win32 Shell API
> > > >
> > > >
> > > > Ok. Now I tested to copy multiple files with a single call. Did work. No
> > > > problem with the examples I found.
> > > >
> > > > Back to my previous question: What is wrong with the available examples?
> > > >
> > > > By the way: I started off by googling for
> > > > "copying multiple files with SHFileOperation"
> > > >
> > > > /Per W
> > > >
> > > > On Tue, 17 May 2005, Guillermo Gutierrez wrote:
> > > >
> > > > > I have tried looking on google and have found only the same old tired examples of how to delete files using the operation or how to copy a file with it and how it "should" work to copy multiple files.
> > > > >
> > > > > I need to copy 10 - 50 files from a rather long path and have not been successful using it.
> > > > >
> > > > > Is that enough info for your liking? or if you like you can go into your world, ignore my email, and let someone who cares answer back.
> > > > >
> > > > > -----Original Message-----
> > > > > From: Per Westermark [mailto:pw...@ia...]
> > > > > Sent: Tuesday, May 17, 2005 12:16 PM
> > > > > To: Guillermo Gutierrez
> > > > > Cc: dev...@li...
> > > > > Subject: Re: [Dev-C++] Win32 Shell API
> > > > >
> > > > >
> > > > > Can we expect you to repeat this question until somehow someone new to
> > > > > this list and takes the time to write something about it? It takes quite
> > > > > some time to write the answer you like. You can, on the other hand, find
> > > > > that information without too much google magic.
> > > > >
> > > > > This is your - at least - third mail about requests for help with shell
> > > > > copy. And while discussing shell copy - you haven't even mentioned any
> > > > > special reason for your desperate need for use of this specific function,
> > > > > or why the answer must come from this list instead of from google.
> > > > >
> > > > > If the google links contains wrong information, or wrong type of
> > > > > information, just say so and specify exactly what makes your requirements
> > > > > completely different from other peoples.
> > > > >
> > > > > /Per W
> > > > >
> > > > > On Tue, 17 May 2005, Guillermo Gutierrez wrote:
> > > > >
> > > > > > Does any one out there have any experience with Windows Shell API?
> > > > > > Particularly with copying files using 'SHFileOperation()' ?
> > > > > >
> > > > > > Guillermo Gutierrez
> > > > > > Market Scan Information Systems
> > > > > > Software Q.A. Supervisor
> > > > > > (818) 575-2000 x2427
> > > > > > ggu...@ma...
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
>
|