diff --git a/ChangeLog b/ChangeLog index f16633ef2de6ad0ac117c2f45bbc47a4baf34266..475c8ab7a60a6dfa1018cb87fe191fe25b04342c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-07-02 Chris Allegretta <chrisa@asty.org> + * src/files.c (do_lockfile): Check whether the directory + of the file we're trying to lock exists, and make the + resulting error message more intuitive. Fixes + Savannah bug 42639 by bens. + 2014-07-02 Mark Majeres <mark@engine12.com> * src/text.c (undo_cut, redo_cut, update_undo): Handle the cases of cutting-from-cursor-to-end-of-line correctly. diff --git a/src/files.c b/src/files.c index 18baacc35fabc574cd0cddeb290c86b649b307b7..97a2e88e51a65f6c95552f3c865bc2c8b688baed 100644 --- a/src/files.c +++ b/src/files.c @@ -141,7 +141,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi mypid = getpid(); if (gethostname(myhostname, 31) < 0) { - statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno)); + statusbar(_("Couldn't determine hosttname for lock file: %s"), strerror(errno)); return -1; } @@ -247,6 +247,7 @@ int do_lockfile(const char *filename) size_t lockfilesize = strlen(filename) + strlen(locking_prefix) + strlen(locking_suffix) + 3; char *lockfilename = charalloc(lockfilesize); + char *lockfilecpy = NULL; char lockprog[12], lockuser[16]; struct stat fileinfo; int lockfd, lockpid; @@ -294,8 +295,17 @@ int do_lockfile(const char *filename) blank_statusbar(); return -1; } + } else { + lockfilecpy = mallocstrcpy(NULL, lockfilename); + lockfilecpy = dirname(lockfilecpy); + if (stat(lockfilename, &fileinfo) == -1) { + statusbar(_("Error writing lock file: Directory \'%s\' doesn't exist"), + lockfilecpy); + return -1; + } } + return write_lockfile(lockfilename, filename, FALSE); } #endif /* !NANO_TINY */