DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: ┃ T m

⟦0f346f15b⟧ TextFile

    Length: 799 (0x31f)
    Types: TextFile
    Names: »mkdir.c«

Derivation

└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki
    └─ ⟦this⟧ »EUUGD11/euug-87hel/sec3/localtime/mkdir.c« 

TextFile

#

/*LINTLIBRARY*/

#include "stdio.h"

#ifndef lint
#ifndef NOID
static char	sccsid[] = "@(#)mkdir.c	7.5";
#endif /* !NOID */
#endif /* !lint */

extern FILE *	popen();

static
quote(name, fp)
register char *	name;
register FILE *	fp;
{
	register int	c;

	(void) fputc('\'', fp);
	if (name != NULL)
		while ((c = *name++) != '\0')
			if (c == '\'')
				(void) fprintf(fp, "'\\''");
			else	(void) fputc(c, fp);
	(void) fputc('\'', fp);
}

mkdir(name, mode)
char *	name;
{
	register FILE *	fp;
	register int	oops;

	if ((fp = popen("sh", "w")) == NULL)
		return -1;
	(void) fprintf(fp, "mkdir 2>&- ");
	quote(name, fp);
	(void) fprintf(fp, " && chmod 2>&- %o ", mode);
	quote(name, fp);
	(void) fputc('\n', fp);
	(void) fflush(fp);
	oops = ferror(fp);
	return (pclose(fp) == 0 && !oops) ? 0 : -1;
}