#/bin/sh
# Copyright (c) 2000, FundsXpress Financial Network, Inc.
# This library is free software released "AS IS WITH ALL FAULTS"
# and WITHOUT ANY WARRANTIES under the terms of the GNU Lesser
# General Public License, Version 2.1, a copy of which can be
# found in the "COPYING" file of this distribution.

pathname=$1
mode=$2
[ -z "$mode" ] && mode=755
OLDIFS="$IFS"; IFS=/; set $pathname; IFS="$OLDIFS"

case $pathname in
    /*)	partial=/;  ;;
    *)	partial=""; ;;
esac

for i do
    if [ ! -z "$i" ]; then
	partial="$partial$i"
	if [ ! -d $partial ]; then
	  mkdir $partial || exit 1;
	  chmod $mode $partial
	fi
	partial="$partial/"
    fi
done
