1#! /bin/sh
2################################################################################
3##                                                                            ##
4## Copyright (c) International Business Machines  Corp., 2001                 ##
5##                                                                            ##
6## This program is free software;  you can redistribute it and#or modify      ##
7## it under the terms of the GNU General Public License as published by       ##
8## the Free Software Foundation; either version 2 of the License, or          ##
9## (at your option) any later version.                                        ##
10##                                                                            ##
11## This program is distributed in the hope that it will be useful, but        ##
12## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
14## for more details.                                                          ##
15##                                                                            ##
16## You should have received a copy of the GNU General Public License          ##
17## along with this program;  if not, write to the Free Software		      ##
18## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
19##									      ##
20################################################################################
21#
22# File:			unzip_genfile.sh
23#
24# Description:	This program will generate the zip file that will be used to
25#               test the unzip program.
26#
27# Author:		Manoj Iyer manjo@mail.utexas.edu
28#
29# History:
30# 	Mar 03 2003 - Created - Manoj Iyer.
31
32# Create directories and fill them with files.
33
34numdirs=3                     # number of directories to create
35numfiles=3                    # number of file to create in each directory
36dirname=$1		      # name of the base directory
37dircnt=0                      # index into number of dirs created in loop
38fcnt=0                        # index into number of files created in loop
39RC=0                          # return value from commands
40
41while [ $dircnt -lt $numdirs ]
42do
43	dirname=$dirname/d.$dircnt
44	mkdir -p $dirname || RC=$?
45	if [ $RC -ne 0 ]
46	then
47		echo "$0: ERROR: while creating $numdirs dirs." 1>&2
48		exit $RC
49	fi
50	fcnt=0
51	while [ $fcnt -lt $numfiles ]
52	do
53		touch $dirname/f.$fcnt
54		if [ $RC -ne 0 ]
55		then
56			echo "$0: ERROR: creating $numdirs dirs." 1>&2
57			exit $RC
58		fi
59		fcnt=$(($fcnt+1))
60	done
61	dircnt=$(($dircnt+1))
62done
63