---
name: "mkpath_np"
section: "3"
platform: "macos"
package: "Libc"
version: "1752.120.2"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/mkpath_np"
---

# mkpath\_np(3)

Auxiliary routine for efficiently creating paths

## NAME

**mkpath\_np** – Auxiliary routine for efficiently creating paths

## SYNOPSIS

**#include \<unistd.h\>**

*int*\

**mkpath\_np**(*const char \* path*, *mode\_t omode*);

## DESCRIPTION

This routine allows the caller to create a path, including intermediate directories.  It is equivalent to calling [mkdir(1)](/mkdir/1.md) with the -p command line argument.

Intermediate directories are created with permission bits of rwxrwxrwx (0777) as modified by the current umask, plus write and search permission for the owner.

The leaf directory is created with permission bits of *omode* as modified by the current umask.

## RETURN VALUES

A 0 return value indicates success.  If an error occurs, the return value is a non-zero error code.  Note that EEXIST is returned iff the leaf directory already exists and is a directory, so under certain circumstances, this error value may not indicate a failure state.

This routine does NOT modify errno.

## ERRORS

Any error code that can be returned by [mkdir(2)](/mkdir/2.md) can be returned by **mkpath\_np**(), but **mkpath\_np**() will return the error code rather than setting errno.

- \[ENOTDIR\]

  A component of the path is not a directory (in contrast to [mkdir(2)](/mkdir/2.md) which returns this based on the path prefix rather than the path).

- \[EEXIST\]

  The path already exists and is a directory.

## HISTORY

This function first appeared in iOS 5.0.

## SEE ALSO

[mkdir(1)](/mkdir/1.md), [chmod(2)](/chmod/2.md), [mkdir(2)](/mkdir/2.md)
