About the function for opening a file in a folderI was just looking at making a OpenAndSelect function that could be useful elsewhere. I did not test on any system other than my Linux Mint system so it would need to be tested on other systems.
I am sure that in Linux every file manager should show help
-h. It is enough to read it and make sure that the parameters are correct.
Unfortunately
explorer.exe in
Windows does not give any help with any parameter (
-? -h /? /h /help), but there is an
archived article on the Mircosoft website. I have been using its parameter
/select, for a long time, and it definitely works in
Windows 7/8. It is strange that the comma after the parameter is required...
After checking the help of file managers, you can suggest this function on the bug tracker, where developers on other platforms will check it and leave a review. For example, I am not sure, but
/expand for
explorer can be useful. And probably it is better to explicitly specify the extension
.exe for it.
About the code:* You accidentally specified
/bin/sh in
TProcess for all platforms, so the folder does not open on
Windows. It is better to use the full command line for each variant and pass it "
AProcess.CommandLine := FileManagerCmd;"
* All
{$IFDEF} should be converted to
{$IF}/
{$ELSEIF} and
{$ELSE} for other platforms, since the
FileManagerCmd variable is not even initialized for them now. For them, you can simply call
OpenDocument for the parent folder. Please note the
example of correct use of directives.
* The "
if not FileExists(SourceFilePath) then" check doesn't always work. The file may be virtual (not yet saved by the project), but the old file may exist on disk. Hopefully
Martin will tell you the correct way to check, as this is not my area of expertise.
* "
OpenAndSelect"? I can suggest the names "
OpenInFolder", "
SelectInFolder".