taco-db  0.1.0
Functions
pgmkdirp.h File Reference

Declares pg_mkdir_p() adapted from PostgreSQL. More...

#include "tdb.h"

Go to the source code of this file.

Functions

int pg_mkdir_p (char *path, int omode)
 Creates a directory and, if necessary, parent directories. More...
 

Detailed Description

Declares pg_mkdir_p() adapted from PostgreSQL.

See COPYRIGHT and the function doc for a copyright notice.

Function Documentation

◆ pg_mkdir_p()

int pg_mkdir_p ( char *  path,
int  omode 
)

Creates a directory and, if necessary, parent directories.

This function is adapted from pg_mkdir_p() in PostgreSQL's src/port/pgmkdirp.c.

This is equivalent to "mkdir -p" except we don't complain if the target directory already exists.

We assume the path is in canonical form, i.e., uses / as the separator.

omode is the file permissions bits for the target directory. Note that any parent directories that have to be created get permissions according to the prevailing umask, but with u+wx forced on to ensure we can create there. (We declare omode as int, not mode_t, to minimize dependencies for port.h.)

Returns 0 on success, -1 (with errno set) on failure.

Note that on failure, the path arg has been modified to show the particular directory level we had problems with.