Chinaunix首页 | 论坛 | 博客
  • 博客访问: 772966
  • 博文数量: 143
  • 博客积分: 2077
  • 博客等级: 大尉
  • 技术积分: 2393
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-28 12:57
文章存档

2016年(2)

2015年(3)

2014年(3)

2013年(41)

2012年(94)

分类: LINUX

2013-04-28 18:13:23

/** mkdir1.c
 ** ------------------------------------------------------------
	A version of mkdir that supports the -p option is:
	sol04.15.c.
	This program allows multiple names on the command line.

 ** ------------------------------------------------------------
 **
 **
 *  A version of mkdir that supports the -p option
 *
 *  usage: mkdir1 [-p] dir1 [dir2 ..]
 *
 *  exits with code 1 if any error
 */

#include 
#include 
#include 
#include 
#include 
#include  
#include 
#include 
#include 

#define	MODE	0755	/* will be modified by umask */
int
main(int ac, char *av[])
{
	int	p_flag = 0;
	int	rv = 0;

	p_flag = check_args(ac,av);
	while(rv == 0 && --ac)
		if ( **++av != '-' )
			if ( do_mkdir(*av, p_flag) == -1 )
				rv = 1;
	return rv;
}

/*
 * check_args(int ac, char *av[])
 * returns a boolean value indicating if a -p has been seen
 */
int check_args(int ac, char *av[])
{
	int	i;

	for(i=1; i                                   
阅读(1913) | 评论(0) | 转发(0) |
0

上一篇:more

下一篇:mv filename filename/dirname

给主人留下些什么吧!~~