blob: 94fe21ae0e6c3f26e591a79859babacafb388bfd (
plain) (
tree)
|
|
function! write_mkpath#(path) abort
" Path exists, we don't need to do anything
if isdirectory(a:path)
return
endif
" If :write! was issued, we'll try to create the path; failing that, if
" 'confirm' is enabled, and the user responds affirmatively to the prompt,
" that will do, too. Otherwise, we will allow the write to fail.
if v:cmdbang
let l:mkpath = 1
elseif &confirm
let l:mkpath = confirm('Create path '.a:path.'?', "&Yes\n&No") == 1
else
let l:mkpath = 0
endif
" If we decided to attempt a path creation, do so
if l:mkpath
call mkdir(a:path, 'p')
endif
endfunction
|