orbea / cross / slibtool

Forked from cross/slibtool 3 years ago
Clone

Blame src/internal/slibtool_mkdir_impl.h

3895af
/*******************************************************************/
3895af
/*  slibtool: a skinny libtool implementation, written in C        */
78d96a
/*  Copyright (C) 2016--2017  Z. Gilboa                            */
3895af
/*  Released under the Standard MIT License; see COPYING.SLIBTOOL. */
3895af
/*******************************************************************/
3895af
3895af
#include <errno.h>
3895af
#include <unistd.h>
3895af
3895af
#ifndef O_DIRECTORY
3895af
#define O_DIRECTORY 0
3895af
#endif
3895af
3895af
static inline int slbt_mkdir(const char * path)
3895af
{
3895af
	int fdlibs;
3895af
3895af
	if ((fdlibs = open(path,O_DIRECTORY)) >= 0)
3895af
		close(fdlibs);
3895af
	else if ((errno != ENOENT) || mkdir(path,0777))
3895af
		if (errno != EEXIST)
3895af
			return -1;
3895af
3895af
	return 0;
3895af
}