Re: [PATCH 11/13] introduce relative_filename and use it

Pedro Alves
2013-08-27T13:44:34Z

On 08/23/2013 09:36 PM, Tom Tromey wrote:
> +# ROOT and FULL are file names. Returns the relative path from ROOT
> +# to FULL. Note that FULL must be in a subdirectory of ROOT.

Would it be a good idea to "error" out on mistakes here?

> + return [eval file join [lrange [file split $full] $len end]]

> +# For example, given ROOT = /usr/bin and FULL = /usr/bin/ls, this
> +# will return "ls".
> +
> +proc relative_filename {root full} {
> + set len [llength [file split $root]]
> + return [eval file join [lrange [file split $full] $len end]]
> +}

I think we'd just have to make sure full[1..len] equals root.

--
Pedro Alves