Loading ...
Sorry, an error occurred while loading the content.

72889Re: Bug: Erroneous "Cannot create directory" in "mkdir('foo/bar/', 'p')"

Expand Messages
  • Marius Gedminas
    Aug 21, 2013
      On Wed, Aug 21, 2013 at 01:56:31PM +0300, LCD 47 wrote:
      > On 20 August 2013, David Barnett <daviebdawg@...> wrote:
      > > Ensure ./foo doesn't exist, and do
      > > :call mkdir('foo/bar/', 'p')
      > >
      > > Vim gives you an error:
      > > E739: Cannot create directory: foo/bar/
      > > but the directory was created just fine.
      > >
      > > Dropping the trailing slash works without error:
      > > :call mkdir('foo/bar', 'p')
      >
      > Please try the patch below. It kills the trailing slash, which
      > seems pretty awkward for a fix.


      > diff -r ae6c19fb32e1 src/eval.c
      > --- a/src/eval.c Wed Aug 14 17:45:29 2013 +0200
      > +++ b/src/eval.c Wed Aug 21 13:49:19 2013 +0300
      > @@ -14284,6 +14284,7 @@
      > typval_T *rettv;
      > {
      > char_u *dir;
      > + char_u *p;
      > char_u buf[NUMBUFLEN];
      > int prot = 0755;
      >
      > @@ -14292,6 +14293,13 @@
      > return;
      >
      > dir = get_tv_string_buf(&argvars[0], buf);
      > + p = gettail(dir);
      > + if (!*p)
      > + {
      > + p = gettail_sep(dir);
      > + *p = 0;
      > + }
      > +

      What about :call mkdir('foo/bar//', 'p')?

      > if (argvars[1].v_type != VAR_UNKNOWN)
      > {
      > if (argvars[2].v_type != VAR_UNKNOWN)
      > @@ -14299,7 +14307,7 @@
      > if (prot != -1 && STRCMP(get_tv_string(&argvars[1]), "p") == 0)
      > mkdir_recurse(dir, prot);
      > }
      > - rettv->vval.v_number = prot != -1 ? vim_mkdir_emsg(dir, prot) : 0;
      > + rettv->vval.v_number = prot != -1 ? vim_mkdir_emsg(dir, prot) : FAIL;
      > }
      > #endif

      Marius Gedminas
      --
      Hacking graphics in X is like finding sqrt(pi) with roman numerals.
      -- man xdaliclock
    • Show all 9 messages in this topic