libite 2.6.1
makepath.c File Reference
#include <errno.h>
#include <libgen.h>
#include <stdarg.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "lite.h"

Go to the source code of this file.

Functions

int mkpath (const char *dir, mode_t mode)
 
int fmkpath (mode_t mode, const char *fmt,...)
 
int makepath (const char *dir)
 

Detailed Description

Author
Joachim Wiberg
Date
2013-2021

Definition in file makepath.c.

Function Documentation

◆ fmkpath()

int fmkpath ( mode_t mode,
const char * fmt,
... )

Formatted version of mkpath().

Parameters
modeA mode_t mode to create directories with
fmtFormatted string to be composed into a pathname
Note
Notice the swapped arguments, compared to mkpath()!
Returns
POSIX OK(0) on success, otherwise -1 with errno set.

Definition at line 66 of file makepath.c.

◆ makepath()

int makepath ( const char * dir)

Create all components of the specified directory.

Parameters
dirDirectory to create.
Note
It is strongly recommended to use mkpath() over this function since it has the mode argument while this function default to 0777, which in most cases is insecure.
Returns
POSIX OK (0) on success, otherwise -1 and errno set appropriately.
Exceptions
EINVALon bad argument, or
ENOMEMwhen it fails allocating temporary memory.

For other error codes see the mkdir(2) syscall description.

Definition at line 105 of file makepath.c.

◆ mkpath()

int mkpath ( const char * dir,
mode_t mode )

makepath() but takes a mode_t argument.

Parameters
dirDirectory to created, relative or absolute
modeA &mode_t mode to create dir with
Returns
POSIX OK(0) on success, otherwise -1 with errno set.

Definition at line 40 of file makepath.c.