#!/bin/sh
if [ "$1" == "" ]
then
	echo false
	echo error: type of access unknown >&2
	exit 0
fi
type=$1

if [ "$type" != "get" -a "$type" != "put" ]
then
	echo false
	echo error: $type type of access unknown >&2
	exit 1
fi
shift

if [ "$1" == "" ]
then
	echo false
	echo error: path unknown >&2
	exit 1
fi
path=$1

shift
user=$1

if [ "$type" == "get" ]
then 
	if [ ! -f $path  ]
	then
		echo false
		echo file $path does not exists >&2
		exit 1
	fi
else
	if [ -f $path ]
	then
		echo false
		echo file $path exists, can not overwrite >&2
		exit 1
	fi

	dir=`dirname $path`
	if [ ! -d $dir ]
	then
		echo false
		echo directory $dir does not exists or is not a directory >&2
		exit 1
	fi
fi

echo true
exit 0

