#!/bin/bash
# Help functions for KMediaFactory scripts.
# Copyright (C) 2007 by Petri Damsten - GPL-2

function check_executable
{
  if [[ "$KMF_WINID" == "" ]]; then
    EMBED=""
  else
    EMBED="--embed $KMF_WINID"
  fi
  if [[ "$3" != "" ]]; then
    if [ -e "$3/$1" ]; then
      BIN="$3/$1"
    fi
  fi
  if [[ "$BIN" == "" ]]; then
    BIN=`which $1`
  fi

  if [ $? -eq 0 ]; then
    echo $BIN
  else
    kdialog --title "KMediaFactory" $EMBED --sorry \
"Cannot continue because $1 was not found from your system.\n\
Please install package $2 (or similar)."
    exit 1
  fi
}

function link_target
{
  LS_OUT=$(ls -l "$1")
  BASE=`dirname $1`
  TARGET="$BASE/${LS_OUT#*-> }"
  echo $TARGET
}