firasuke / cross / slibtool

Forked from cross/slibtool 3 months ago
Clone

Blame src/internal/slibtool_mkdir_impl.h

3895af
/*******************************************************************/
3895af
/*  slibtool: a skinny libtool implementation, written in C        */
6803d8
/*  Copyright (C) 2016--2018  Z. Gilboa                            */
3895af
/*  Released under the Standard MIT License; see COPYING.SLIBTOOL. */
3895af
/*******************************************************************/
3895af
089c8b
#ifndef SLIBTOOL_MKDIR_IMPL_H
089c8b
#define SLIBTOOL_MKDIR_IMPL_H
089c8b
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
}
089c8b
089c8b
#endif