maybe_create_winetc ()
{
  local FILES="hosts protocols services networks"
  local WINSYS32HOME="$(/usr/bin/cygpath -S -w)"
  local WINETC="${WINSYS32HOME}\\drivers\\etc"

  if [ ! -d "${WINETC}" ]; then
    echo "Directory ${WINETC} does not exist; exiting" >&2
    echo "If directory name is garbage you need to update your msys package" >&2
    exit 1
  fi

  local mketc=
  for mketc in ${FILES}
  do
    if [ ! -e "/etc/${mketc}" -a ! -L "/etc/${mketc}" ]
    then
      # Windows only uses the first 8 characters
      local WFILE="${WINETC}\\$(expr substr "${mketc}" 1 8)"
      /usr/bin/cp -p -v "${WFILE}" "/etc/${mketc}"
    fi
  done

  /usr/bin/chmod 1777 /tmp 2>/dev/null
}

maybe_create_winetc
