How to copy a symbolic link file from Linux to Windows and then back to Linux, but still saving it as a symbolic link

I have a symlink on my Linux machine.

I want to copy only the symbolic link (not the target) to the Windows computer, and then copy this symbolic link from the Windows machine back to another Linux machine, and the symbolic link should continue to work.

What I tried:

  • I set a symbolic link
  • Moved gzipped file to a Windows computer using WinSCP
  • Extracted symlink
  • Moved symbolic file to Linux machine using WinSCP

Now this file is no longer a symbolic link.

Does anyone know a trick to do this?

+5
3

* nix " ". . "symlink" Windows. , Windows, [ , , ]. * nix .

"symlink" .

, .

.

  1. WinSCP: , WinSCP. . put . ln . , (symlink = ). symlink ( , . ).

  2. : ZIP. ( Windows) PHP- ZipArchive::setExternalAttributes ZipArchive::setExternalAttributes . , PHP 5.6.

    :

    $symlink = true; // is symlink?
    $dir = false; // is folder?
    $mode = "755"; // permissions
    
    $local_path = "C:\\zip\\folder\\mylink";
    $zip_path = "folder/mylink";
    
    $attr = 
        (1 << 14) | // this bit seems to be always set
        (1 << ($dir ? 30 : 31)) |
        ($symlink ? (1 << 29) : 0) |
        octdec($mode) << 16;
    
    $zip->addFile($local_path, $zip_path);
    $zip->setExternalAttributesName($zip_path, ZipArchive::OPSYS_UNIX, $attr);
    

    Python, . () ZIP Python zipfile? , , PHP.

+4

gzip ( tar.gz) Linux-. , Windows linux, , , - .

linux script, ln ,

#!/bin/bash
ln -s TARGET LINKNAME

, Linux , Linux-.

+3

1. VirtualBox

VirtualBox rsync tar- Windows (NTFS).

VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

, .

2. Windows Linux (WSL)

Windows Linux (WSL), tar NTFS. . tar .

However, while WSL is only available on 64-bit versions of Windows 10 and can be activated in the Windows 10 Anniversary Update and later. Also note that at present (2018-01-21) the file date is not restored correctly .

0
source

Source: https://habr.com/ru/post/1538671/


All Articles