+2016-01-31 Benno Schulenberg <bensberg@justemail.net>
+ * src/files.c (has_valid_path): Be more specific in how a given path
+ is invalid. The change was improved by Rishabh Dave.
+
2016-01-29 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (do_insertfile): Do display the buffer when configured
with only --disable-histories. This fixes Savannah bug #47011.
{
char *parentdir;
struct stat parentinfo;
- bool validity = TRUE;
+ bool validity = FALSE;
if (strrchr(filename, '/') == NULL)
parentdir = mallocstrcpy(NULL, ".");
else
parentdir = dirname(mallocstrcpy(NULL, filename));
- if (stat(parentdir, &parentinfo) == -1 || !S_ISDIR(parentinfo.st_mode)) {
- statusbar(_("Directory '%s' does not exist"), parentdir);
- validity = FALSE;
- beep();
+ if (stat(parentdir, &parentinfo) == -1) {
+ if (errno == ENOENT)
+ statusbar(_("Directory '%s' does not exist"), parentdir);
+ else
+ statusbar(_("Path '%s': %s"), parentdir, strerror(errno));
+ } else if (!S_ISDIR(parentinfo.st_mode)) {
+ statusbar(_("Path '%s' is not a directory"), parentdir);
+ } else {
+ if (access(parentdir, X_OK) == -1)
+ statusbar(_("Path '%s' is not accessible"), parentdir);
+ else
+ validity = TRUE;
}
free(parentdir);
+
+ if (!validity)
+ beep();
+
return validity;
}
#endif
void do_uncut_text(void);
-/* All functions in files.c. */
-void verify_path(const char *filename);
+/* Most functions in files.c. */
void make_new_buffer(void);
void initialize_buffer_text(void);
bool open_buffer(const char *filename, bool undoable);