summaryrefslogtreecommitdiffhomepage
path: root/src/internal/slibtool_mkdir_impl.h
blob: 4cb3a27f03b921a89fc7864a1edbf01cabae889c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*******************************************************************/
/*  slibtool: a skinny libtool implementation, written in C        */
/*  Copyright (C) 2016--2018  Z. Gilboa                            */
/*  Released under the Standard MIT License; see COPYING.SLIBTOOL. */
/*******************************************************************/

#include <errno.h>
#include <unistd.h>

#ifndef O_DIRECTORY
#define O_DIRECTORY 0
#endif

static inline int slbt_mkdir(const char * path)
{
	int fdlibs;

	if ((fdlibs = open(path,O_DIRECTORY)) >= 0)
		close(fdlibs);
	else if ((errno != ENOENT) || mkdir(path,0777))
		if (errno != EEXIST)
			return -1;

	return 0;
}