1*5891Sraf /* 2*5891Sraf * CDDL HEADER START 3*5891Sraf * 4*5891Sraf * The contents of this file are subject to the terms of the 5*5891Sraf * Common Development and Distribution License (the "License"). 6*5891Sraf * You may not use this file except in compliance with the License. 7*5891Sraf * 8*5891Sraf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5891Sraf * or http://www.opensolaris.org/os/licensing. 10*5891Sraf * See the License for the specific language governing permissions 11*5891Sraf * and limitations under the License. 12*5891Sraf * 13*5891Sraf * When distributing Covered Code, include this CDDL HEADER in each 14*5891Sraf * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5891Sraf * If applicable, add the following below this CDDL HEADER, with the 16*5891Sraf * fields enclosed by brackets "[]" replaced with your own identifying 17*5891Sraf * information: Portions Copyright [yyyy] [name of copyright owner] 18*5891Sraf * 19*5891Sraf * CDDL HEADER END 20*5891Sraf */ 21*5891Sraf 22*5891Sraf /* 23*5891Sraf * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24*5891Sraf * Use is subject to license terms. 25*5891Sraf */ 26*5891Sraf 27*5891Sraf #pragma ident "%Z%%M% %I% %E% SMI" 28*5891Sraf 29*5891Sraf /* Copyright (c) 1988 AT&T */ 30*5891Sraf /* All Rights Reserved */ 31*5891Sraf 32*5891Sraf #include "synonyms.h" 33*5891Sraf #include <sys/types.h> 34*5891Sraf #include <sys/stat.h> 35*5891Sraf #include <unistd.h> 36*5891Sraf #include "libc.h" 37*5891Sraf 38*5891Sraf int 39*5891Sraf remove(const char *filename) 40*5891Sraf { 41*5891Sraf struct stat64 statb; 42*5891Sraf 43*5891Sraf /* 44*5891Sraf * If filename is not a directory, call unlink(filename) 45*5891Sraf * Otherwise, call rmdir(filename) 46*5891Sraf */ 47*5891Sraf 48*5891Sraf if (lstat64(filename, &statb) != 0) 49*5891Sraf return (-1); 50*5891Sraf if ((statb.st_mode & S_IFMT) != S_IFDIR) 51*5891Sraf return (unlink(filename)); 52*5891Sraf return (rmdir(filename)); 53*5891Sraf } 54