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