1

[Question] Can WinSCP handle Junction directory?

I am using C++/CLI to program a SFTP program using WinSCP .NET assembly (version 5.5.3). My program reads in a schedule file. Originally the source path for get file has to be absolute path. Now that I have to support relative path, I encounter a problem.

Following is to try to get all text files in the home directory. Of course, I want to get all text files within all sub directories inside home directory as well. So I use:

transferOptionObject->FileMask = "*.txt";
transferResult = sftpSession->GetFiles(".", "C:\\temp\\receive", false, 
                 transferOptionObject);

Suppose we use this account terry to log in the remote computer, the remote home directory is /C/Users/terry/Documents. From the session->DebugLog file, I find out WinSCP tries to go over all files and directories within the home directory.

The list is:

* a.txt
* firstDirectory
* My Music
* My Photos
* My Videso
* OtherDirectory
* Other.txt

WinSCP goes over each item in the list. After processing firstDirectory, it tries to process My Music. However it returns an error as not able to process because of Permission Denied.

I then go to the server, and do a dir. I find out those 3 'My' directories are [Junction] as:

29-Apr-14  09:44    <DIR>          .
29-Apr-14  09:44    <DIR>          ..
16-Jan-14  09:48    <DIR>          Documents
16-Jan-14  09:45    <JUNCTION>     My Music [C:\Users\terry\Music]
16-Jan-14  09:45    <JUNCTION>     My Pictures [C:\Users\terry\Pictures]
16-Jan-14  09:45    <JUNCTION>     My Videos [C:\Users\terry\Videos]

I go over these and find out these: Topic "Sync is broken" ;; Tracker Bug 1132 ;; Topic: "WinSCP doesn't check hardlink target date when synchronizing"

Are they related?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992

1 Answers1

0

As it's a remote junction/folder, and the SFTP protocol does not know anything about junctions, it's all about your SFTP server. This has nothing to do with client (WinSCP), as it cannot even know it's a junction. Your SFTP server most likely simply presents the junction as a folder. Although it could also present it as a symlink to a folder (but in that case WinSCP would silently skip it).


Side note: The path to the remote target directory should end with a slash.
See https://winscp.net/eng/docs/library_session_getfiles

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1) Luckily, user of my program says there should not be any case of getting files using wildcard (e.g. *.txt) in the home directory. 2) My program has to handle the relative path! So I use `"."` 3) For path must end with slash/backslash, both these are successful. Case a) Get file, file with wildcard, I use `GetFiles(dir name before wildcard file without ending /, local dir name without ending \\)`. Case b) Get file, file without wildcard, I use `GetFiles(full path with file name, local dir name with \\)`. For SyncDir, I get correct result with no ending slash/backslash. – Just a HK developer May 14 '14 at 08:28