Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlink to file:// repos by adding ?symlink suffix #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

patmaddox
Copy link

@patmaddox patmaddox commented Oct 21, 2022

(note: I haven't written C++ in ~20 years! all suggestions welcome)

I posted in the forum dev thread asking about workflow for developing reapacks. I found it a bit clunky to develop by adding scripts directly via actions, and then to elsewhere add a package.

It would be nice to install a package locally so it symlinks to files. Then as you edit the scripts, Reaper will pick up the updates automatically, just like if you added the scripts directly without ReaPack.

To use it, append ?symlink to a file:// repo URL, e.g. file:///path/to/my/index.xml?symlink. Install (or reinstall) a package, and it will symlink the files instead of copying them. Reaper picks up any changes you make to the script.

Tested on MacOS 10.15.6, REAPER 6.68

@patmaddox patmaddox changed the title Proof of concept: Symlink to file:/// paths Symlink to file:/// paths Oct 21, 2022
@patmaddox patmaddox changed the title Symlink to file:/// paths Symlink to file:// repos by adding ?symlink suffix Oct 21, 2022
@patmaddox patmaddox force-pushed the symlinks branch 10 times, most recently from 4bf6753 to 3c16aea Compare October 21, 2022 10:59
const auto &nativeLink = nativePath(link);

#ifdef _WIN32
return CreateSymbolicLink(nativeLink.c_str(), target.c_str(), 0x0);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what to do here... I've tried a bunch of different variations. I don't have a windows machine, so it takes ~15 minutes for CI to provide feedback.

Copy link
Owner

@cfillion cfillion Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows API needs UTF-16 wchar_t strings instead of UTF-8 char strings:

return CreateSymbolicLink(nativeLink.c_str(), Win32::widen(target).c_str(), 0);

(CreateSymbolicLink is an alias for CreateSymbolicLinkW. CreateSymbolicLinkA takes const char*, but its character set is limited to whatever the current system ANSI codepage is.)

Also I'm pretty sure Windows requires the process to gain admin privileges to be allowed to create symlinks... (And the SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag requires Developer Mode to be enabled.) If so I don't think this will be acceptable as a feature, or it will need to only be available on Linux/macOS...

Anyway, I'll check & review the PR more closely later on. Thanks for the PR!

Copy link
Author

@patmaddox patmaddox Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I changed it to use Path and now the Windows build went green.

I hope you will consider including it, even if we have to disable support for it on Windows. It's super handy.

@patmaddox patmaddox force-pushed the symlinks branch 2 times, most recently from 6bc81ee to 79e9c5b Compare October 21, 2022 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants