"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/File.cpp" between
xfe-1.42.tar.gz and xfe-1.43.tar.gz

About: Xfe (X File Explorer) is a file manager and browser (using the FOX toolkit).

File.cpp  (xfe-1.42):File.cpp  (xfe-1.43)
skipping to change at line 398 skipping to change at line 398
} }
FXuint answer = dlg->execute(PLACEMENT_OWNER); FXuint answer = dlg->execute(PLACEMENT_OWNER);
delete dlg; delete dlg;
restartTimeout(); restartTimeout();
return(answer); return(answer);
} }
// Copy ordinary file // Copy ordinary file
// Return 0 to allow displaying an error message in the calling function
// Return -1 to prevent displaying an error message in the calling function
// Return -2 when an error has occurred during the copy
int File::copyfile(const FXString& source, const FXString& target, const FXbool preserve_date) int File::copyfile(const FXString& source, const FXString& target, const FXbool preserve_date)
{ {
FXString destfile; FXString destfile;
FXuchar buffer[32768]; FXuchar buffer[32768];
struct stat info; struct stat info;
struct utimbuf timbuf; struct utimbuf timbuf;
FXlong nread, nwritten; FXlong nread, nwritten;
FXlong size, dataread = 0; FXlong size, dataread = 0;
int src, dst; int src, dst;
int ok = false; int ok = false;
skipping to change at line 429 skipping to change at line 432
} }
else else
{ {
destfile = target; destfile = target;
} }
// Copy file block by block // Copy file block by block
size = info.st_size; size = info.st_size;
if ((dst = ::open(destfile.text(), O_WRONLY|O_CREAT|O_TRUNC, info.st _mode)) >= 0) if ((dst = ::open(destfile.text(), O_WRONLY|O_CREAT|O_TRUNC, info.st _mode)) >= 0)
{ {
int error = false;
while (1) while (1)
{ {
errno = 0; errno = 0;
nread = File::fullread(src, buffer, sizeof(buffer)); nread = File::fullread(src, buffer, sizeof(buffer));
int errcode = errno; int errcode = errno;
if (nread < 0) if (nread < 0)
{ {
forceTimeout(); forceTimeout();
FXString str; FXString str;
skipping to change at line 458 skipping to change at line 463
FXuint answer = mbox->execute(PLACEMENT_OWNER); FXuint answer = mbox->execute(PLACEMENT_OWNER);
restartTimeout(); restartTimeout();
if (answer == BOX_CLICKED_CANCEL) if (answer == BOX_CLICKED_CANCEL)
{ {
::close(dst); ::close(dst);
::close(src); ::close(src);
cancelled = true; cancelled = true;
return(false); return(false);
} }
else
{
error = true; // An error
has occurred
}
} }
if (nread == 0) if (nread == 0)
{ {
break; break;
} }
// Force timeout checking for progress dialog // Force timeout checking for progress dialog
checkTimeout(); checkTimeout();
// Set percentage value for progress dialog // Set percentage value for progress dialog
skipping to change at line 549 skipping to change at line 558
FXuint answer = mbox->execute(PLACEMENT_OWNER); FXuint answer = mbox->execute(PLACEMENT_OWNER);
restartTimeout(); restartTimeout();
if (answer == BOX_CLICKED_CANCEL) if (answer == BOX_CLICKED_CANCEL)
{ {
::close(dst); ::close(dst);
::close(src); ::close(src);
cancelled = true; cancelled = true;
return(false); return(false);
} }
else
{
error = true; // An error
has occurred
}
} }
} }
ok = true;
// An error has occurred during the copy
if (error)
{
ok = -2;
}
else
{
ok = true;
}
::close(dst); ::close(dst);
// Keep original date if asked // Keep original date if asked
if (preserve_date) if (preserve_date)
{ {
timbuf.actime = info.st_atime; timbuf.actime = info.st_atime;
timbuf.modtime = info.st_mtime; timbuf.modtime = info.st_mtime;
errno = 0; errno = 0;
int rc = utime(destfile.text(), &timbuf); int rc = utime(destfile.text(), &timbuf);
int errcode = errno; int errcode = errno;
skipping to change at line 630 skipping to change at line 653
mbox->setText(str); mbox->setText(str);
FXuint answer = mbox->execute(PLACEMENT_OWNER); FXuint answer = mbox->execute(PLACEMENT_OWNER);
restartTimeout(); restartTimeout();
if (answer == BOX_CLICKED_CANCEL) if (answer == BOX_CLICKED_CANCEL)
{ {
cancelled = true; cancelled = true;
return(false); return(false);
} }
ok = -1; // Prevent displaying an error message ok = -1; // Prevent displaying an error message
// in the calling function // in the calling function
} }
return(ok); return(ok);
} }
// Copy directory // Copy directory
int File::copydir(const FXString& source, const FXString& target, struct stat& p arentinfo, inodelist* inodes, const FXbool preserve_date) int File::copydir(const FXString& source, const FXString& target, struct stat& p arentinfo, inodelist* inodes, const FXbool preserve_date)
{ {
DIR* dirp; DIR* dirp;
struct dirent* dp; struct dirent* dp;
struct stat linfo; struct stat linfo;
skipping to change at line 1136 skipping to change at line 1159
mbox->setText(str); mbox->setText(str);
FXuint answer = mbox->execute(PLACEMENT_OWNER); FXuint answer = mbox->execute(PLACEMENT_OWNER);
restartTimeout(); restartTimeout();
if (answer == BOX_CLICKED_CANCEL) if (answer == BOX_CLICKED_CANCEL)
{ {
cancelled = true; cancelled = true;
return(false); return(false);
} }
return(-1); // To prevent displaying an error message return(-1); // To prevent displaying an error message
// in the calling function // in the calling function
} }
else else
{ {
return(true); return(true);
} }
} }
} }
return(-1); return(-1);
} }
skipping to change at line 1336 skipping to change at line 1359
{ {
// Hide progress dialog and restart timer // Hide progress dialog and restart timer
forceTimeout(); forceTimeout();
restartTimeout(); restartTimeout();
return(true); return(true);
} }
} }
// Get the size of the source // Get the size of the source
FXulong srcsize = 0; FXulong srcsize = 0;
struct stat linfo; struct stat linfo;
if (lstatrep(source.text(), &linfo) == 0) if (lstatrep(source.text(), &linfo) == 0)
{ {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
if (S_ISDIR(linfo.st_mode)) // Folder if (S_ISDIR(linfo.st_mode)) // Folder
{ {
FXuint nbfiles = 0, nbsubfolders = 0; FXuint nbfiles = 0, nbsubfolders = 0;
FXulong totalsize=0; FXulong totalsize=0;
strlcpy(buf, source.text(), source.length()+1); strlcpy(buf, source.text(), source.length()+1);
srcsize = pathsize(buf, &nbfiles, &nbsubfolders,&totalsize); srcsize = pathsize(buf, &nbfiles, &nbsubfolders,&totalsize);
skipping to change at line 1401 skipping to change at line 1424
forceTimeout(); forceTimeout();
MessageBox::error(this, BOX_OK, _("Error"), _("Can't rename to target %s : %s"), targetfile.text(), strerror(errcode)); MessageBox::error(this, BOX_OK, _("Error"), _("Can't rename to target %s : %s"), targetfile.text(), strerror(errcode));
return(-1); return(-1);
} }
// If files are on different file systems, use the copy/delete scheme and pr eserve the original date // If files are on different file systems, use the copy/delete scheme and pr eserve the original date
totaldata -= srcsize; // Avoid counting data twice totaldata -= srcsize; // Avoid counting data twice
int ret = this->copy(source, target, false, true); int ret = this->copy(source, target, false, true);
// Success
if (ret == true) if (ret == true)
{ {
return(remove(source.text()) == true); return(remove(source.text()) == true);
} }
// Error during copy
else if (ret == -2)
{
return true;
}
// Operation cancelled
else else
{ {
return(false); return(false);
} }
} }
// Symbolic Link file (no progress dialog) // Symbolic Link file (no progress dialog)
// Return 0 to allow displaying an error message in the calling function // Return 0 to allow displaying an error message in the calling function
// Return -1 to prevent displaying an error message in the calling function // Return -1 to prevent displaying an error message in the calling function
int File::symlink(const FXString& source, const FXString& target) int File::symlink(const FXString& source, const FXString& target)
skipping to change at line 2029 skipping to change at line 2061
// Perform the mount/unmount command // Perform the mount/unmount command
FILE* pcmd = popen(cmd.text(), "r"); FILE* pcmd = popen(cmd.text(), "r");
if (!pcmd) if (!pcmd)
{ {
MessageBox::error(this, BOX_OK, _("Error"), _("Failed command: %s"), cmd .text()); MessageBox::error(this, BOX_OK, _("Error"), _("Failed command: %s"), cmd .text());
return(-1); return(-1);
} }
// Get error message if any // Get error message if any
char text[10000] = { 0 }; char text[10000] = { 0 };
FXString buf; FXString buf;
while (fgets(text, sizeof(text), pcmd)) while (fgets(text, sizeof(text), pcmd))
{ {
buf += text; buf += text;
} }
snprintf(text, sizeof(text)-1, "%s", buf.text()); snprintf(text, sizeof(text)-1, "%s", buf.text());
// Close the stream // Close the stream
if ((pclose(pcmd) == -1) && (strcmp(text, "") != 0)) if ((pclose(pcmd) == -1) && (strcmp(text, "") != 0))
{ {
MessageBox::error(this, BOX_OK, _("Error"), "%s", text); MessageBox::error(this, BOX_OK, _("Error"), "%s", text);
return(-1); return(-1);
} }
// Hide progress dialog // Hide progress dialog
hide(); hide();
// Success message, eventually // Success message, eventually
if (mount_messages) if (mount_messages)
{ {
if (op == MOUNT) if (op == MOUNT)
{ {
MessageBox::information(this, BOX_OK, _("Success"), _("Folder %s was successfully mounted."), dir.text()); MessageBox::information(this, BOX_OK, _("Success"), _("Folder %s was successfully mounted."), dir.text());
} }
 End of changes. 12 change blocks. 
5 lines changed or deleted 40 lines changed or added

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