"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "mcopy.c" between
mtools-4.0.35.tar.bz2 and mtools-4.0.36.tar.bz2

About: Mtools is a collection of utilities to access MS-DOS disks from Unix without mounting them.

mcopy.c  (mtools-4.0.35.tar.bz2):mcopy.c  (mtools-4.0.36.tar.bz2)
/* Copyright 1986-1992 Emmet P. Gray. /* Copyright 1986-1992 Emmet P. Gray.
* Copyright 1994,1996-2002,2007-2009 Alain Knaff. * Copyright 1994,1996-2002,2007-2009,2021 Alain Knaff.
* This file is part of mtools. * This file is part of mtools.
* *
* Mtools is free software: you can redistribute it and/or modify * Mtools is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Mtools is distributed in the hope that it will be useful, * Mtools is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 163 skipping to change at line 163
fprintf(stderr,"\n"); fprintf(stderr,"\n");
} }
if(got_signal) { if(got_signal) {
return ERROR_ONE; return ERROR_ONE;
} }
if ((Target = SimpleFileOpen(0, 0, unixFile, if ((Target = SimpleFileOpen(0, 0, unixFile,
O_WRONLY | O_CREAT | O_TRUNC, O_WRONLY | O_CREAT | O_TRUNC,
errmsg, 0, 0, 0))) { errmsg, 0, 0, 0))) {
mt_off_t ret = 0; mt_off_t ret;
if(needfilter && arg->textmode){ Source = COPY(File);
Source = open_filter(COPY(File),arg->convertCharset); if(needfilter && arg->textmode)
if (!Source) Source = open_dos2unix(Source,arg->convertCharset);
ret = -1;
} else
Source = COPY(File);
if (ret == 0 ) if (Source)
ret = copyfile(Source, Target); ret = copyfile(Source, Target);
else
ret = -1;
FREE(&Source); FREE(&Source);
FREE(&Target); FREE(&Target);
if(ret <= -1){ if(ret < 0){
if(!arg->type) if(!arg->type)
unlink(unixFile); unlink(unixFile);
return ERROR_ONE; return ERROR_ONE;
} }
if(!arg->type) if(!arg->type)
set_mtime(unixFile, mtime); set_mtime(unixFile, mtime);
return GOT_ONE; return GOT_ONE;
} else { } else {
fprintf(stderr,"%s\n", errmsg); fprintf(stderr,"%s\n", errmsg);
return ERROR_ONE; return ERROR_ONE;
skipping to change at line 288 skipping to change at line 287
char *longname, char *longname,
void *arg0, void *arg0,
direntry_t *entry) direntry_t *entry)
{ {
Stream_t *Target; Stream_t *Target;
time_t now; time_t now;
int type; int type;
mt_off_t ret; mt_off_t ret;
uint32_t fat; uint32_t fat;
time_t date; time_t date;
mt_off_t filesize, newsize; mt_off_t filesize;
Arg_t *arg = (Arg_t *) arg0; Arg_t *arg = (Arg_t *) arg0;
Stream_t *Source = COPY(arg->mp.File);
if (arg->mp.File->Class->get_data(arg->mp.File, if (Source->Class->get_data(Source, &date, &filesize,
& date, &type, 0) < 0 ){
&filesize, &type, 0) < 0 ){
fprintf(stderr, "Can't stat source file\n"); fprintf(stderr, "Can't stat source file\n");
return -1; return -1;
} }
if(fileTooBig(filesize)) { if(fileTooBig(filesize)) {
fprintf(stderr, "File \"%s\" too big\n", longname); fprintf(stderr, "File \"%s\" too big\n", longname);
return 1; return 1;
} }
if (type){ if (type){
skipping to change at line 331 skipping to change at line 331
else else
getTimeNow(&now); getTimeNow(&now);
mk_entry(dosname, arg->attr, 1, 0, now, &entry->dir); mk_entry(dosname, arg->attr, 1, 0, now, &entry->dir);
Target = OpenFileByDirentry(entry); Target = OpenFileByDirentry(entry);
if(!Target){ if(!Target){
fprintf(stderr,"Could not open Target\n"); fprintf(stderr,"Could not open Target\n");
exit(1); exit(1);
} }
if (arg->needfilter & arg->textmode) if (arg->needfilter & arg->textmode) {
Target = open_filter(Target,arg->convertCharset); Source = open_unix2dos(Source,arg->convertCharset);
}
ret = copyfile(arg->mp.File, Target); ret = copyfile(Source, Target);
GET_DATA(Target, 0, &newsize, 0, &fat); GET_DATA(Target, 0, 0, 0, &fat);
FREE(&Source);
FREE(&Target); FREE(&Target);
if (arg->needfilter & arg->textmode)
newsize++; /* ugly hack: we gathered the size before the Ctrl-Z
* was written. Increment it manually */
if(ret < 0 ){ if(ret < 0 ){
fat_free(arg->mp.targetDir, fat); fat_free(arg->mp.targetDir, fat);
return -1; return -1;
} else { } else {
mk_entry(dosname, arg->attr, fat, (uint32_t)newsize, mk_entry(dosname, arg->attr, fat, (uint32_t)ret,
now, &entry->dir); now, &entry->dir);
return 0; return 0;
} }
} }
static int dos_write(direntry_t *entry, MainParam_t *mp, int needfilter) static int dos_write(direntry_t *entry, MainParam_t *mp, int needfilter)
/* write a messy dos file to another messy dos file */ /* write a messy dos file to another messy dos file */
{ {
int result; int result;
Arg_t * arg = (Arg_t *) (mp->arg); Arg_t * arg = (Arg_t *) (mp->arg);
 End of changes. 12 change blocks. 
22 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)