tweaks: reshuffle two declarations plus a fragment of code
Also, don't bother statting the path that the user provided, as that case will happen right away in the next 'if'.master
parent
b3374ea1fb
commit
75a70d98d5
17
src/files.c
17
src/files.c
|
@ -899,26 +899,25 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||||
* obtained fd otherwise. *f is set to the opened file. */
|
* obtained fd otherwise. *f is set to the opened file. */
|
||||||
int open_file(const char *filename, bool new_one, FILE **f)
|
int open_file(const char *filename, bool new_one, FILE **f)
|
||||||
{
|
{
|
||||||
struct stat fileinfo, fileinfo2;
|
|
||||||
int fd;
|
|
||||||
char *full_filename = get_full_path(filename);
|
char *full_filename = get_full_path(filename);
|
||||||
|
struct stat fileinfo;
|
||||||
|
int fd;
|
||||||
|
|
||||||
/* If the full path is unusable (due to some component's permissions),
|
/* If the full path is unusable (due to some component's permissions),
|
||||||
* but the relative path is okay, then just use that one. */
|
* but the relative path is okay, then just use that one. */
|
||||||
if (full_filename == NULL || (stat(full_filename, &fileinfo) == -1 &&
|
if (full_filename == NULL || stat(full_filename, &fileinfo) == -1)
|
||||||
stat(filename, &fileinfo2) != -1))
|
|
||||||
full_filename = mallocstrcpy(full_filename, filename);
|
full_filename = mallocstrcpy(full_filename, filename);
|
||||||
|
|
||||||
if (stat(full_filename, &fileinfo) == -1) {
|
if (stat(full_filename, &fileinfo) == -1) {
|
||||||
|
free(full_filename);
|
||||||
|
|
||||||
if (new_one) {
|
if (new_one) {
|
||||||
statusbar(_("New File"));
|
statusbar(_("New File"));
|
||||||
free(full_filename);
|
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
statusline(ALERT, _("File \"%s\" not found"), filename);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
statusline(ALERT, _("File \"%s\" not found"), filename);
|
|
||||||
free(full_filename);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
|
|
Loading…
Reference in New Issue