Skip to main content
Module

x/denops_std/function/mod.ts>mkdir

📚 Standard module for denops.vim
Go to Latest
function mkdir
import { mkdir } from "https://deno.land/x/denops_std@v6.4.0/function/mod.ts";

Create directory {name}.

When {flags} is present it must be a string. An empty string has no effect.

If {flags} contains "p" then intermediate directories are created as necessary.

If {flags} contains "D" then {name} is deleted at the end of the current function, as with:

defer delete({name}, 'd')

If {flags} contains "R" then {name} is deleted recursively at the end of the current function, as with:

defer delete({name}, 'rf')

Note that when {name} has more than one part and "p" is used some directories may already exist. Only the first one that is created and what it contains is scheduled to be deleted. E.g. when using:

call mkdir('subdir/tmp/autoload', 'pR')

and "subdir" already exists then "subdir/tmp" will be scheduled for deletion, like with:

defer delete('subdir/tmp', 'rf')

Note that if scheduling the defer fails the directory is not deleted. This should only happen when out of memory.

If {prot} is given it is used to set the protection bits of the new directory. The default is 0o755 (rwxr-xr-x: r/w for the user, readable for others). Use 0o700 to make it unreadable for others. This is only used for the last part of {name}. Thus if you create /tmp/foo/bar then /tmp/foo will be created with 0o755. Example:

:call mkdir($HOME .. "/tmp/foo/bar", "p", 0o700)

This function is not available in the sandbox.

There is no error if the directory already exists and the "p" flag is passed (since patch 8.0.1708). However, without the "p" option the call will fail.

The function result is a Number, which is TRUE if the call was successful or FALSE if the directory creation failed or partly failed.

Not available on all systems. To check use:

:if exists("*mkdir")

Can also be used as a method:

GetName()->mkdir()

Parameters

denops: Denops
name: unknown
optional
flags: unknown
optional
prot: unknown

Returns

Promise<number>