Skip to content

Commit

Permalink
Merge branch 'patch-1' of github.com:Maczuga/GooglePhotosTakeoutHelpe…
Browse files Browse the repository at this point in the history
…r into Maczuka-patch-1
  • Loading branch information
TheLastGimbus committed Mar 24, 2024
2 parents 6ddd94a + ea9b579 commit 09d332d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/moving.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ File findNotExistingName(File initialFile) {
///
/// WARN: Crashes with non-ascii names :(
Future<File> createShortcut(Directory location, File target) async {
final name = '${p.basename(target.path)}${Platform.isWindows ? '.lnk' : ''}';
final name = p.basename(target.path);
final link = findNotExistingName(File(p.join(location.path, name)));
// this must be relative to not break when user moves whole folder around:
// https://github.com/TheLastGimbus/GooglePhotosTakeoutHelper/issues/232
final targetRelativePath = p.relative(target.path, from: link.parent.path);
if (Platform.isWindows) {
final res = await Process.run(
'powershell.exe',
workingDirectory: link.parent.path,
[
'-ExecutionPolicy',
'Bypass',
'-NoLogo',
'-NonInteractive',
'-NoProfile',
'-Command',
'\$ws = New-Object -ComObject WScript.Shell; '
'\$s = \$ws.CreateShortcut(\'${link.path}\'); '
'\$s.TargetPath = \'$targetRelativePath\'; '
'\$s.Save()',
'New-Item -ItemType SymbolicLink '
'-Path \'${link.path}\' '
'-Target \'$targetRelativePath\'',
],
);
if (res.exitCode != 0) {
Expand Down

0 comments on commit 09d332d

Please sign in to comment.