FreeBSD/usr.bin/catman/catman.c
/*
 * If the directory exists, attempt to make it writable, otherwise
 * attempt to create it.
 */
If the directory exists, attempt to make it writable, otherwise
attempt to create it.
If the directory exists attempt to make it writable otherwise attempt to create it .
static int
make_writable_dir(char *mandir, char *dir)
{
	int test;
	if ((test = test_path(dir, NULL)) != 0) {
		if (!(test & TEST_WRITABLE) && chmod(dir, 0755) < 0) {
			warn("%s/%s: chmod", mandir, dir);
			exit_code = 1;
			return 0;
		}
	} else {
		if (verbose || pretend)
			fprintf(stderr, "mkdir %s\n", dir);
		if (!pretend) {
			unlink(dir);
			if (mkdir(dir, 0755) < 0) {
				warn("%s/%s: mkdir", mandir, dir);
				exit_code = 1;
				return 0;
			}
		}
	}
	return 1;
}
static int make_writable_dir ( char * mandir , char * dir ) { int test ; if ( ( test = test_path ( dir , NULL ) ) != 0 ) { if ( ! ( test & TEST_WRITABLE ) && chmod ( dir , 0755 ) < 0 ) { warn ( " " , mandir , dir ) ; exit_code = 1 ; return 0 ; } } else { if ( verbose || pretend ) fprintf ( stderr , " \n " , dir ) ; if ( ! pretend ) { unlink ( dir ) ; if ( mkdir ( dir , 0755 ) < 0 ) { warn ( " " , mandir , dir ) ; exit_code = 1 ; return 0 ; } } } return 1 ; }
If the directory exists, attempt to make it writable, otherwise
 attempt to create it.
If the directory exists attempt to make it writable otherwise attempt to create it .