|
From: Per W. <pw...@ia...> - 2005-05-18 18:11:39
|
Calling strxxx() functions non-standard sounds a bit amusing given the
fact that they are part of a large number of standards and also used in
multidigit billion lines of code...
Anyway, yes std::string works perfectly well to use.
std::string s;
std::string separator;
separator.append("\0",1);
s += "file1.txt";
s += separator;
s += "file2.txt";
s += separator;
...
const char* psz = s.c_str();
/Per W
On Wed, 18 May 2005, Guillermo Gutierrez wrote:
> Yes, that is most likely what I will end up doing next now that I have gotten it to work with the C character arrays.
>
> -----Original Message-----
> From: Mat...@Ve...
> [mailto:Mat...@Ve...]
> Sent: Wednesday, May 18, 2005 9:18 AM
> To: Guillermo Gutierrez
> Subject: RE: FW: [Dev-C++] Win32 Shell API
>
>
> Just use STL strings for each.
> Don't do all this weird nonstandard stuff with C character arrays.
> Then use the c_str() function to pass the data out of the string in C
> format.
>
> -----Original Message-----
> From: dev...@li...
> [mailto:dev...@li...]On Behalf Of Guillermo
> Gutierrez
> Sent: Tuesday, May 17, 2005 4:20 PM
> To: Per Westermark
> Cc: dev...@li...
> Subject: RE: FW: [Dev-C++] Win32 Shell API
>
>
> 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...
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by Oracle Space Sweepstakes
> Want to be the first software developer in space?
> Enter now for the Oracle Space Sweepstakes!
> http://ads.osdn.com/?ad_idt12&alloc_id344&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> ___________________________________________________________________
> The information contained in this message and any attachment may be
> proprietary, confidential, and privileged or subject to the work
> product doctrine and thus protected from disclosure. If the reader
> of this message is not the intended recipient, or an employee or
> agent responsible for delivering this message to the intended
> recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited.
> If you have received this communication in error, please notify me
> immediately by replying to this message and deleting it and all
> copies and backups the
|