Page 1 of 2
Linked files with hard link
Posted: 21 Jul 2021 10:38
by zakoul
There is a utility
FindLinks from sysinternals that displays all files associated with a hard link.
Is there such a possibility in the XYplorer? So that when you select a file with a hard link, all associated files are displayed.
Re: Linked files with hard link
Posted: 21 Jul 2021 11:07
by highend
No, because fsutil would need to be invoked to get that info
Code: Select all
$results = trim(runret("""fsutil"" hardlink list ""<curitem>""", , 65001), <crlf>);
$cntResults = gettoken($results, "count", <crlf>);
if ($cntResults >= 2) {
$drive = gpc(<curitem>, "drive") . ":";
$hardlinks = gettoken($results, $cntResults - 1, <crlf>, , 1);
$hardlinks = regexreplace($hardlinks, "^(.)", $drive . "$1");
$header = "Hardlink(s) to <curitem>";
$output = $header . <crlf> . strrepeat("=", strlen($header)) . <crlf> . $hardlinks;
text $output;
}
You can see where a file points to but that requires hovering over a hardlink, not its source...
Re: Linked files with hard link
Posted: 21 Jul 2021 11:21
by zakoul
Thank you. Works.
Re: Linked files with hard link
Posted: 21 Jul 2021 11:23
by highend
If there are no hardlinks pointing to the selected file, no, nothing will happen
Re: Linked files with hard link
Posted: 21 Jul 2021 11:57
by zakoul
The last link does not display

Re: Linked files with hard link
Posted: 21 Jul 2021 12:10
by highend
Yeah, fsutil is a bit weird sometimes (at one time the source file is listed first, on other occasions as the last entry)
This should avoid it:
Code: Select all
$results = runret("""fsutil"" hardlink list ""<curitem>""", , 65001);
$escaped = regexreplace(substr(<curitem>, 2), "([\\.+(){\[^$])", "\$1");
$results = trim(regexreplace($results, "^$escaped(\r?\n|$)"), <crlf>);
$cntResults = gettoken($results, "count", <crlf>);
if ($cntResults >= 1) {
$drive = gpc(<curitem>, "drive") . ":";
$results = regexreplace($results, "^(.)", $drive . "$1");
$header = "Hardlink(s) to " . quote(<curitem>);
$output = $header . <crlf> . strrepeat("=", strlen($header)) . <crlf> . $results;
text $output;
}
Re: Linked files with hard link
Posted: 21 Jul 2021 12:41
by zakoul
Is it possible to draw a conclusion in a non-modal window? Or tear it off right in your notepad.exe.
When "text $output" is displayed, the explorer is not available.
Re: Linked files with hard link
Posted: 21 Jul 2021 12:55
by highend
Then use something like
Code: Select all
writefile("%TEMP%\~fsutil.txt", $output, , "utf8");
run """notepad.exe"" ""%TEMP%\~fsutil.txt""";
instead of
Re: Linked files with hard link
Posted: 21 Jul 2021 13:07
by zakoul
Thank you.
Re: Linked files with hard link
Posted: 21 Jul 2021 13:28
by zakoul
Last moment. If nothing is selected (click on an empty space), then the window is displayed. Can I fix this, if not difficult?

Re: Linked files with hard link
Posted: 21 Jul 2021 13:34
by highend
Code: Select all
if (!<get CountSelected>) { end true; }
?
Re: Linked files with hard link
Posted: 21 Jul 2021 13:38
by zakoul
Re: Linked files with hard link
Posted: 21 Jul 2021 16:00
by zakoul
highend, Found a problem with symbols.

Re: Linked files with hard link
Posted: 21 Jul 2021 16:28
by highend
Try to replace
Code: Select all
$results = runret("""fsutil"" hardlink list ""<curitem>""", , 65001);
with
Code: Select all
$cmd = <<<>>>
cmd /c @chcp 65001 >NUL 2>NUL & fsutil hardlink list "<curitem>"
>>>;
$results = runret("$cmd", , 65001);
Re: Linked files with hard link
Posted: 26 Jul 2021 18:52
by zakoul
Can't get information from folder \Systems32\
