formatting and cosmetic fixes
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2139 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
ca018c3e23
commit
e08765dca5
15
src/files.c
15
src/files.c
|
@ -349,18 +349,20 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
||||||
} else if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
} else if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) ||
|
||||||
S_ISBLK(fileinfo.st_mode)) {
|
S_ISBLK(fileinfo.st_mode)) {
|
||||||
/* Don't open character or block files. Sorry, /dev/sndstat! */
|
/* Don't open character or block files. Sorry, /dev/sndstat! */
|
||||||
statusbar(S_ISDIR(fileinfo.st_mode) ? _("\"%s\" is a directory") :
|
statusbar(S_ISDIR(fileinfo.st_mode) ? _("\"%s\" is a directory")
|
||||||
_("File \"%s\" is a device file"), filename);
|
: _("File \"%s\" is a device file"), filename);
|
||||||
return -1;
|
return -1;
|
||||||
} else if ((fd = open(filename, O_RDONLY)) == -1) {
|
} else if ((fd = open(filename, O_RDONLY)) == -1) {
|
||||||
statusbar(_("Error reading %s: %s"), filename, strerror(errno));
|
statusbar(_("Error reading %s: %s"), filename, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
/* File is A-OK. */
|
/* File is A-OK. Open it in binary mode for our own end-of-line
|
||||||
*f = fdopen(fd, "rb"); /* Binary for our own line-end munging */
|
* character munging. */
|
||||||
|
*f = fdopen(fd, "rb");
|
||||||
|
|
||||||
if (*f == NULL) {
|
if (*f == NULL) {
|
||||||
statusbar(_("Error reading %s: %s"), filename, strerror(errno));
|
statusbar(_("Error reading %s: %s"), filename,
|
||||||
|
strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
} else
|
} else
|
||||||
statusbar(_("Reading File"));
|
statusbar(_("Reading File"));
|
||||||
|
@ -1373,9 +1375,11 @@ int write_file(const char *name, bool tmp, int append, bool
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
anyexists = (lstat(realname, &lst) != -1);
|
anyexists = (lstat(realname, &lst) != -1);
|
||||||
|
|
||||||
/* New case: if the file exists, just give up. */
|
/* New case: if the file exists, just give up. */
|
||||||
if (tmp && anyexists)
|
if (tmp && anyexists)
|
||||||
goto cleanup_and_exit;
|
goto cleanup_and_exit;
|
||||||
|
|
||||||
/* If NOFOLLOW_SYMLINKS is set, it doesn't make sense to prepend or
|
/* If NOFOLLOW_SYMLINKS is set, it doesn't make sense to prepend or
|
||||||
* append to a symlink. Here we warn about the contradiction. */
|
* append to a symlink. Here we warn about the contradiction. */
|
||||||
if (ISSET(NOFOLLOW_SYMLINKS) && anyexists && S_ISLNK(lst.st_mode)) {
|
if (ISSET(NOFOLLOW_SYMLINKS) && anyexists && S_ISLNK(lst.st_mode)) {
|
||||||
|
@ -1469,6 +1473,7 @@ int write_file(const char *name, bool tmp, int append, bool
|
||||||
|
|
||||||
/* Copy the file. */
|
/* Copy the file. */
|
||||||
copy_status = copy_file(f, backup_file);
|
copy_status = copy_file(f, backup_file);
|
||||||
|
|
||||||
/* And set metadata. */
|
/* And set metadata. */
|
||||||
if (copy_status != 0 || chown(backupname,
|
if (copy_status != 0 || chown(backupname,
|
||||||
originalfilestat.st_uid, originalfilestat.st_gid) == -1
|
originalfilestat.st_uid, originalfilestat.st_gid) == -1
|
||||||
|
|
Loading…
Reference in New Issue