Hi Frank,
FA> Is it a good idea to allow wildcards in the destination ?
FA> I mean as a simple copy function, especially with the use of '/y'
FA> could be disastrous.
Yes, I see your point but once I have a fully qualified output
path/name for the destination it's a simple matter to check for the
existence of a file with that filespec and ask for permission before
over-writting.
One of the main reasons I don't want to keep using the DOS copy
command from within my program is it's lack of return codes. As the
routine is also used to do a move using, copy then delete, there are some
_big_ problems associated with it, especially if I miss an error message
before the screen is updated. I know this is not the best way to do a move
but at the moment it's the best I can do.
FA> I may just play with this, and let you know:)
That would be appreciated. I have also received a reply which
included a rather large chunk of source code which looks like it contains
what I need. This will take me a bit of time to sort out as it's written
in Pascal and I need to translate it. Should give me something to do for
a while.
FA> Does PCC support fnsplit ? It would make your life a bit easier.
No, it doesn't but I downloaded a snippets file a couple of days
ago which includes the source for psplit(), which I believe will do the
same thing.
========================================================================
I was about to post this message when I got sidetracked with the
coding. I beleive I have it! It will need a bit more testing but it does
appear to do what I wanted. I have attached the source for your interest.
It will abviously need a bit of re-writing to use with a different compiler
and you probably have library routines to perform some of the functions.
You will notice that I have used the pslit() routine mentioned above,
although slightly modified.
One thing I found interesting is that DOS will allow you to create
a file with the same name as the volume name, even in the root directory.
Once testing is complete I intend to tidy the whole lot up and
start the optimising process, possibly re-writing it in assembler. I would
be interested in any comments you may have, as well as any sugestions. It
was your routine which made it a very much easier job.
Next project: How to do a move without a copy if the destination is
the same drive as the source. That would save quite a bit of time with
large files. Any thoughts?
Thanks again Frank.
John
========================================================================
/*
NOTE: I just can't seem to be able to make myself
put comments in the code
*/
#include
#define NULL 0
#define TRUE 0
#define FALSE !TRUE
#define MAXPATH 160
main(argc, argv) /* need to start with source and dest */
int argc;
char *argv[];
{
char source[MAXPATH], dest[MAXPATH];
strcpy(source, argv[1]);
strcpy(dest, argv[2]);
if (argc<3)
dest[0]=0;
if (argc<2)
source[0]=0;
c_copy(source,dest,argc,0);
}
c_copy(src, dst, vars, mode)
char *src, *dst;
int vars, mode;
{
struct DTA f;
char source_name[MAXPATH];
char sourcefile[MAXPATH];
char *ptr;
int done, cnt;
char dest_name[MAXPATH];
long c_bytes;
char c_attrib;
if (done = read_dir_first(src,255,&f))
return FALSE;
for(cnt=0; cnt * Origin: Melbourne PC User Group +61-3-9699-6788 (3:632/309)
SEEN-BY: 50/99 78/0 620/243 623/630 632/0 107 271 304 309 328 348 360 393 525
SEEN-BY: 632/530 552 998 999 1000 633/371 634/384 388 396 635/301 502 503 544
SEEN-BY: 637/103 639/252 670/301 711/401 409 410 413 430 808 809 932 934
SEEN-BY: 712/515 713/888 714/906 800/1 7877/2809
@PATH: 632/309 998 635/503 50/99 711/808 809 934
|