What is the simplest way to check for the existence of a file specified by a file: URL that uses URLEncoding in Tcl 8.5.9?
::http::geturl says it doesn't support file URLs.
file exists requires URLDecoding. There doesn't seem to be a builtin proc for URLDecoding. Have I missed it?
Are there any other builtin ways to do this? Do newer versions of Tcl provide more support for this?
If no builtin way, is there a recommended library for this? Either for directly handling file: URLs, or for URLDecoding?
In my projects, I tend to use a combination of a URI/URL processor (uri::split) plus a URL decoder (urlDecode) for postprocessing:
Step 1: URL processing
Step 2: URL (percent-) decoding
Source the following:
Then:
Depending on the portability and robustness aimed at, you might want to use
file normalize& friends.