FileURI plugin for Take Command / TCC / TCC/LE
Version 1.1.1 2024-10-17
Charles Dye
Purpose:
This plugin implements functions to convert local filenames to the
file:// representation and vice versa.
Installation:
To use this plugin, copy FileURI.dll to
some known location on your hard drive. (If you are still using the 32-bit
version of Take Command, take FileURI-x86.dll
instead of FileURI.dll.) Load the plugin
with a PLUGIN /L command, for example:
plugin /l c:\bin\tcmd\test\fileuri.dll
If you copy this file to a subdirectory named PlugIns within your Take Command program directory, the plugin will be loaded automatically when TCC starts.
Plugin Features:
New functions: @FILE2URI,
@FILE2URIS, @ISURL,
@URI2FILE
New hotkey: Ctrl-Alt-U
New command: FILEURIKEY
Syntax Note:
The syntax definitions in the following text use these conventions for clarity:
BOLD CODE | indicates text which must be typed exactly as shown. |
CODE | indicates optional text, which may be typed as shown or omitted. |
| Bold italic | names a required argument; a value must be supplied. |
| Regular italic | names an optional argument. |
| ellipsis… | after an argument means that more than one may be given. |
New Functions:
@FILE2URI — Converts a
local filename to a file:// URI.
Syntax:
@FILE2URI[filename]
The filename will be canonicalized before conversion; relative pathnames and directory aliases are okay. The file need not actually exist. Note that the string returned by this function may contain percent signs — handle with care!
This function uses UrlCreateFromPath().
@FILE2URIS — Converts a
local filename to a file:// URI.
Syntax:
@FILE2URIS[filename]
The filename will be canonicalized before conversion; relative pathnames and directory aliases are okay. The file need not actually exist. Any percent signs in the resulting URI will be replaced with “safe” percent signs, Unicode character 0xFF05. (These may or may not look like regular percent signs, depending on the font(s) in use.)
This function uses UrlCreateFromPath().
@ISURL — Returns nonzero if
a string represents an internet URL.
Syntax:
@ISURL[string]
This function returns nonzero if string represents an internet URL:
| 0 | not a URL (no protocol specifier) |
| 1 | HTTP:// |
| 2 | HTTPS:// |
| 3 | FTP:// |
| 4 | IFTP session (a filename beginning with FTP:) |
| 5 | TFTP:// |
| 6 | FTPS:// |
| 8 | SFTP:// |
| 10 | other Internet URLs (gopher, mailto, etc.) |
This function simply exposes TCC’s internal QueryIsURL()
function. The operation of this function may differ from version to version of
TCC. For example, TCC/LE does not support the IFTP command, and
so this function won’t return a value of 4 under TCC/LE. Very old
versions of TCC which don’t support SFTP may return a value of 8 for
unknown protocols, and so on.
@URI2FILE — Converts a
file:// URI to a local filename.
Syntax:
@URI2FILE[string]
If the string contains percent signs, you will
need to double them or protect them with strong quotes, escapes, or whatever.
Alternatively, you can use %@CHAR[0xFF05] as a substitute for the
percent sign; the plugin will automatically replace this character with a
percent sign before converting the string.
This function calls PathCreateFromUrl().
New Hotkey:
Ctrl-Alt-U: Toggles the word at the cursor from a filename to a file:// URI, or vice versa.
This hotkey attempts to change the space-delimited word at the cursor. It knows nothing about function arguments, commas, or other argument separators. If you want to use it on an filename inside a function, you must supply spaces around the filename.
Ctrl-Alt-U is the default assignment. You
can use the FILEURIKEY command to change or disable it.
New Command:
FILEURIKEY — View and change
the hotkey assignment.
Syntax:
FILEURIKEY /D /L /Q /R /S key
/D | restore the default plugin settings |
/L | list all supported hotkeys |
/Q | quietly |
/R | restore the saved settings from the registry |
/S | save the current settings to the registry |
| key | the new hotkey, or NONE to disable it |
This command displays and changes plugin settings. At present, the only setting you can change is the hotkey assignment. The default is Ctrl-Alt-U, but you can select a different key, or disable the hotkey altogether. Note that some key combinations may not work for you — they might be intercepted by the console, by a keystroke alias, or by Take Command itself. If your hotkey doesn’t work, try changing it back the the default value.
If you save the current settings to the registry with /S,
they will be reloaded automatically the next time you load this plugin.
FILEURIKEY with no options displays the current settings.
Startup Message:
This plugin displays an informational line when it initializes. The
message will be suppressed in transient or pipe shells. You can disable it
for all shells by defining an environment variable named NOLOADMSG,
for example:
set /e /u noloadmsg=1
Changes:
| Version: | Date: | Changes: |
|---|---|---|
| 1.1.1.1 | 2024-10-17 | Updated the web address in the PLUGININFO structure. |
| 1.1.1 | 2023-07-26 | Updated to the current versions of ParseArgs.cpp and HotKeys.cpp. |
| 1.1.0 | 2021-10-01 | Added a hotkey, and a command to set it. Changed the .dll names; now FileURI.dll is the 64-bit build. Tweaks to the version info structure. Miscellaneous code cleanup. |
| 1.0.0 | 2016-08-23 | First release. |
Status and Licensing:
This plugin is © Copyright 2024, Charles Dye. Unaltered copies of the binary and documentation files may be freely distributed without restriction. I make no guarantee and give no warranty for its operation. If you find a problem, you can report it in the JP Software support forum.
Download:
You can download the current version of the plugin from https://charlesdye.net/dl/fileuri.zip.