<commit_before>#ifndef lint
static const char *rcsid = "$Id: pen.c,v 1.3 1993/09/05 04:54:23 jkh Exp $";
#endif

/*
 * FreeBSD install - a package for the installation and maintainance
 * of non-core utilities.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * <NAME>
 * 18 July 1993
 *
 * Routines for managing the "play pen".
 *
 */

#include "lib.h"
#include <sys/param.h>
#include <sys/mount.h>

/* For keeping track of where we are */
static char Cwd[FILENAME_MAX];
static char Pen[FILENAME_MAX];

static long min_free(char *);

/*
 * Make a temporary directory to play in and chdir() to it, returning
 * pathname of previous working directory.
 */
char *
make_playpen(char *pen, size_t sz)
{
    if (!pen) {
	char *cp;

	if ((cp = getenv("TMPDIR")) != NULL)
	    sprintf(Pen, "%s/instmp.XXXXXX", cp);
	else
	    strcpy(Pen, "/tmp/instmp.XXXXXX");
    }
    else
	strcpy(Pen, pen);
    if (!getcwd(Cwd, FILENAME_MAX))
	upchuck("getcwd");
    if (!mktemp(Pen))
	barf("Can't mktemp '%s'.", Pen);
    if (mkdir(Pen, 0755) == FAIL)
	barf("Can't mkdir '%s'.", Pen);<commit_msg>Be optionally verbose about free-space checking.  I need this to ascertian whether or not this always works.<commit_after>#ifndef lint
static const char *rcsid = "$Id: pen.c,v 1.4 1994/10/04 16:07:50 jkh Exp $";
#endif

/*
 * FreeBSD install - a package for the installation and maintainance
 * of non-core utilities.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * <NAME>
 * 18 July 1993
 *
 * Routines for managing the "play pen".
 *
 */

#include "lib.h"
#include <sys/param.h>
#include <sys/mount.h>

/* For keeping track of where we are */
static char Cwd[FILENAME_MAX];
static char Pen[FILENAME_MAX];

static long min_free(char *);

/*
 * Make a temporary directory to play in and chdir() to it, returning
 * pathname of previous working directory.
 */
char *
make_playpen(char *pen, size_t sz)
{
    if (!pen) {
	char *cp;

	if ((cp = getenv("TMPDIR")) != NULL)
	    sprintf(Pen, "%s/instmp.XXXXXX", cp);
	else
	    strcpy(Pen, "/tmp/instmp.XXXXXX");
    }
    else
	strcpy(Pen, pen);
    if (!getcwd(Cwd, FILENAME_MAX))
	upchuck("getcwd");
    if (!mktemp(Pen))
	barf("Can't mktemp '%s'.", Pen);
    if (mkdir(Pen, 0755) == FAIL)
	barf("Can't mkdir '%s'.", Pen);
    if (Verbose)
	fprintf(stderr, "Projected package size: %d bytes, free space: %d bytes\n", sz, min_free(Pen));
{'fraction_non_alphanumeric': 0.12087246289003332, 'fraction_numerical': 0.016964556195092396, 'mean_word_length': 3.7374461979913915, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '794048', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1038, 'n_words': 397}