Author Topic: Macro support for symbolic folders  (Read 78 times)

0 Members and 1 Guest are viewing this topic.

Offline newbie

  • Occasional poster
  • *
  • Posts: 7
    • View Profile
Macro support for symbolic folders
« on: October 09, 2019, 02:32:17 PM »
Ref: https://www.rejetto.com/wiki/index.php?title=HFS:_scripting_commands
I see the following:
exists | A
checks A for existence, may it be a file or folder.
is file | A
checks A for existence as a file.

and I have been able to use them in Properties:DiffTemplate to check if something is a file or folder.

However, I have not been able to check if a folder is a symbolic link.
Is there a undoc'ed macro for that? Or some other way to do this.
Cause a Search of the forum shows lots of hits for "islink", but it looks like its src code from some .pas file.

Thanks.

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1890
    • View Profile
Re: Macro support for symbolic folders
« Reply #1 on: October 09, 2019, 02:49:52 PM »
directory symlinks are not supported due to a tree continuity issue when returning to parent, however it must be possible to use an external program to return a positive or nil result for this test and use it as a macro alias


Offline newbie

  • Occasional poster
  • *
  • Posts: 7
    • View Profile
Re: Macro support for symbolic folders
« Reply #2 on: October 09, 2019, 03:10:58 PM »
Thanks for responding Mars.

external program? Ok. like the following e.g?

If I type this in a cmd prompt:
fsutil reparsepoint query TestSymFolder | find "Symbolic Link" > nul && echo symlink || echo notsymlink


then it returns back the output:
symlink

Then, how would I call fsutil in the following macro that goes into Properties:DiffTemplate:

[ajax.getfileattr|no log]
{.check session.}
{.set|x|{.postvar|name.}.}
{.break|if={.pos|\|var=x.}{.pos|/|var=x.}|result=forbidden.}
{.set|x|{.force ansi|%folder%{.^x.}.}.}
{.break|if={.not|{.exists|{.^x.}.}.}|result=not found.}
{.break|EXEC FSUTIL && output==symlink | result=symlink.} <===SYNTAX?
{.break|if={.isfile|{.^x.}.}|result=file.}
{.add to log|User %user% get file attrs for "{.^x.}".}
{.pipe|folder.}

P.S:
Also, when my input is a non-symbolic-link folder, the above code returns "file".
Is something wrong with my syntax for this line:
{.break|if={.isfile|{.^x.}.}|result=file.}
« Last Edit: October 09, 2019, 03:29:57 PM by newbie »

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1890
    • View Profile
Re: Macro support for symbolic folders
« Reply #3 on: October 09, 2019, 03:31:47 PM »
have a look on how work the {.exec.} macro with code return of external program in the wiki
http://rejetto.com/forum/index.php?topic=1939.0

Offline newbie

  • Occasional poster
  • *
  • Posts: 7
    • View Profile
Re: Macro support for symbolic folders
« Reply #4 on: October 10, 2019, 01:20:06 PM »
Thank you Mars.

So, this snippet didnt work:
{.set|cmd|{fsutil reparsepoint query {.^x.}| find "Symbolic Link" > nul && echo symlink || echo notsymlink}.}
{.exec|{.^cmd.}|out=#output.}
{.^#output.}

but when I moved the fsutil to a windows.bat file (like the following), it did what I wanted to do:
{.exec|CheckSymlink.bat {.^x.}|out=#output.}
{.^#output.}
So, I'm guessing I messed up the syntax of that exec line in the first snippet.

But, I have another question:
By the way, fsutil assumes the "TestSymFolder" folder lives in the cwd where hfs.exe was executed from.
My HFS env is this:
F:\TestHFS\data is published to <HFS>/test/
F:\TestHFS\data\TestSymFolder is the symbolic linked folder which I am querying.

When I call force ansi
{.set|x|{.force ansi|%folder%{.^x.}.}.}
& use that with fsutil, the folder isnt found cause fsutil is looking at /test/TestSymFolder at the root of the F: drive.

Q: So, is there a macro to get the fully-qualified path to the root of the shared HFS folder i.e F:\TestHFS\data
so that I can supply fsutil with a path like: <FQPath>/TestSymFolder

Thank you.

Offline Mars

  • Operator
  • Tireless poster
  • *****
  • Posts: 1890
    • View Profile
Re: Macro support for symbolic folders
« Reply #5 on: October 10, 2019, 08:56:46 PM »
{.set|x|{.force ansi|%folder-resource%{.^x.}.}.}

Offline newbie

  • Occasional poster
  • *
  • Posts: 7
    • View Profile
Re: Macro support for symbolic folders
« Reply #6 on: October 11, 2019, 01:23:16 PM »
Sweet! That worked. Thanks for (all) your help Mars.