2009-11-03 Chris Allegretta <chrisa@asty.org>
* nano.h - Fix comma at end of enumerator list which angers -pedantic. 2009-11-03 Mike Frysinger <vapier@gentoo.org> * files.c - Move up is_file_writable() to stop implicit definition complaints. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4415 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
a535cecd77
commit
1d461475ce
|
@ -1,3 +1,9 @@
|
|||
2009-11-03 Chris Allegretta <chrisa@asty.org>
|
||||
* nano.h - Fix comma at end of enumerator list which angers -pedantic.
|
||||
|
||||
2009-11-03 Mike Frysinger <vapier@gentoo.org>
|
||||
* files.c - Move up is_file_writable() to stop implicit definition complaints.
|
||||
|
||||
2009-10-27 Chris Allegretta <chrisa@asty.org>
|
||||
* browser.c (browser_init): Set column width to something sane when
|
||||
initializing in a directory with no file entries. Fixes Savannah
|
||||
|
|
83
src/files.c
83
src/files.c
|
@ -291,6 +291,47 @@ bool close_buffer(void)
|
|||
}
|
||||
#endif /* ENABLE_MULTIBUFFER */
|
||||
|
||||
/* A bit of a copy and paste from open_file(), is_file_writable()
|
||||
* just checks whether the file is appendable as a quick
|
||||
* permissions check, and we tend to err on the side of permissiveness
|
||||
* (reporting TRUE when it might be wrong) to not fluster users
|
||||
* editing on odd filesystems by printing incorrect warnings.
|
||||
*/
|
||||
int is_file_writable(const char *filename)
|
||||
{
|
||||
struct stat fileinfo, fileinfo2;
|
||||
int fd;
|
||||
FILE *f;
|
||||
char *full_filename;
|
||||
bool ans = TRUE;
|
||||
|
||||
|
||||
if (ISSET(VIEW_MODE))
|
||||
return TRUE;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
|
||||
/* Get the specified file's full path. */
|
||||
full_filename = get_full_path(filename);
|
||||
|
||||
/* Okay, if we can't stat the path due to a component's
|
||||
permissions, just try the relative one */
|
||||
if (full_filename == NULL
|
||||
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(NULL, filename);
|
||||
|
||||
if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR |
|
||||
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1
|
||||
|| (f = fdopen(fd, "a")) == NULL)
|
||||
ans = FALSE;
|
||||
else
|
||||
fclose(f);
|
||||
close(fd);
|
||||
|
||||
free(full_filename);
|
||||
return ans;
|
||||
}
|
||||
|
||||
/* We make a new line of text from buf. buf is length buf_len. If
|
||||
* first_line_ins is TRUE, then we put the new line at the top of the
|
||||
* file. Otherwise, we assume prevnode is the last line of the file,
|
||||
|
@ -701,48 +742,6 @@ int open_file(const char *filename, bool newfie, FILE **f)
|
|||
return fd;
|
||||
}
|
||||
|
||||
/* A bit of a copy and paste from open_file(), is_file_writable()
|
||||
* just checks whether the file is appendable as a quick
|
||||
* permissions check, and we tend to err on the side of permissiveness
|
||||
* (reporting TRUE when it might be wrong) to not fluster users
|
||||
* editing on odd filesystems by printing incorrect warnings.
|
||||
*/
|
||||
int is_file_writable(const char *filename)
|
||||
{
|
||||
struct stat fileinfo, fileinfo2;
|
||||
int fd;
|
||||
FILE *f;
|
||||
char *full_filename;
|
||||
bool ans = TRUE;
|
||||
|
||||
|
||||
if (ISSET(VIEW_MODE))
|
||||
return TRUE;
|
||||
|
||||
assert(filename != NULL && f != NULL);
|
||||
|
||||
/* Get the specified file's full path. */
|
||||
full_filename = get_full_path(filename);
|
||||
|
||||
/* Okay, if we can't stat the path due to a component's
|
||||
permissions, just try the relative one */
|
||||
if (full_filename == NULL
|
||||
|| (stat(full_filename, &fileinfo) == -1 && stat(filename, &fileinfo2) != -1))
|
||||
full_filename = mallocstrcpy(NULL, filename);
|
||||
|
||||
if ((fd = open(full_filename, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR |
|
||||
S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) == -1
|
||||
|| (f = fdopen(fd, "a")) == NULL)
|
||||
ans = FALSE;
|
||||
else
|
||||
fclose(f);
|
||||
close(fd);
|
||||
|
||||
free(full_filename);
|
||||
return ans;
|
||||
}
|
||||
|
||||
|
||||
/* This function will return the name of the first available extension
|
||||
* of a filename (starting with [name][suffix], then [name][suffix].1,
|
||||
* etc.). Memory is allocated for the return value. If no writable
|
||||
|
|
|
@ -490,7 +490,7 @@ enum
|
|||
BOLD_TEXT,
|
||||
QUIET,
|
||||
UNDOABLE,
|
||||
SOFTWRAP,
|
||||
SOFTWRAP
|
||||
};
|
||||
|
||||
/* Flags for which menus in which a given function should be present */
|
||||
|
|
Loading…
Reference in New Issue