#!/bin/bash

#   FILE: vfstofs -- A script that helps non-GNOME VFS-aware applications
#         open VFS URIs.  This is intended as a temporary solution to make
#         applications like the GIMP and gs more capable players in the GNOME
#         environment.  vfstofs prints the filesystem path equivalent to the
#         supplied URI to stdout.  An example of its use:
#         	gimp `vfstofs FILE:///home/user/foo.xcf`
# AUTHOR: W. Michael Petullo <mike@flyn.org>
#   DATE: 28 July 2003
# 
# Copyright (C) 2003 W. Michael Petullo <mike@flyn.org>
# All rights reserved.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

USAGE="[OPTION]...

  -h, -?   print this message
  -u URI   set the URI to convert  [ $URI ]"

while :;
	do case "$1" in
		-h | "-?" )	
			echo -e usage: ${0##*/} "$USAGE" >&2
			exit 1 ;;
		-u )
			URI=$2
			shift ;;
		-?* )
			echo "${0##*/}: unrecognised option: $1" >&2
			exit 1 ;;
		* )
			break ;;
	esac
	shift
done

if [ -z $URI ]; then
	echo -e usage: ${0##*/} "$USAGE" >&2
	exit 1
fi

case "$URI" in
	[fF][iI][lL][eE]://* )	
		echo $URI | sed 's/^[fF][iI][lL][eE]:\/\///g; s/%20/ /g' ;;
	* )
		echo "${0##*/}: URI not yet supported: $URI" >&2
		exit 1 ;;
esac
