1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

89 Commits

Author SHA1 Message Date
Eduardo C.
a8fc40bd0e Portability: let core build with clang on Linux and Windows (#79)
* Cast between closure types with a functional cast, not reinterpret_cast

A Borland __closure is a built-in (code, data) pair, so reinterpret_cast
between two closure types is allowed. Under standard C++ a closure is a
class, and reinterpret_cast cannot convert one class object into another.
The functional cast is the old C-style cast this line had before
"Refactoring old-style casts" (e5efed895), so C++Builder compiles it as it
did then, and a compiler implementing closures as classes can give it the
same meaning.

* Read the knocked FTP port's IPv4 address as 32 bits

The address is read through an unsigned long pointer. That is 32 bits on
Windows (LLP64), so it reads exactly the four address bytes there; on LP64
targets unsigned long is 64 bits, and the read runs four bytes past the
address into whatever follows it in gethostbyname's buffer. The assignment
to the 32-bit s_addr then keeps the right bytes on little-endian machines,
which is why it goes unnoticed, but the over-read is undefined. ULONG is 32
bits on every Windows compiler, as Windows API layers for POSIX define it
too.

* Compile the synchronize checklist's Explorer file operation on Windows only

TSynchronizeChecklistFileOperation carries out a synchronization checklist
through Explorer's IFileOperation (a Shell COM object), so that local
deletions go to the recycle bin with Explorer's progress and undo. Only
WinSCP's Windows GUI uses it (CustomScpExplorer.cpp). Elsewhere neither the
object nor the interfaces exist, and declaring them only to compile would
pretend to a facility that is not there; a frontend on another platform
implements the operation its own way. The class and its implementation are
guarded with _WIN32, which C++Builder defines, so the Windows build is
unchanged.

* Declare the SIOCATMARK result as ULONG, the type p_ioctlsocket takes

network.c declares ioctlsocket as taking ULONG * (its DECL_WINDOWS_FUNCTION)
but passes a u_long. Both are 32 bits on Windows, so the two agree there. On
an LP64 platform u_long is 64 bits and ULONG 32, so the pointer types differ
and the callee would write half the variable. ULONG is what the declaration
says, and is the same type on Windows.

* Pick aes-ni.c's _mm_setr_epi8 for any GCC-compatible compiler

MM_SETR_EPI8 uses _mm_setr_epi8 only under _WIN64, falling back to a brace
initialiser that is correct for MSVC's __m128i (a byte union) but fills
clang's and GCC's (a two-lane vector) wrongly; the _WIN64 condition fixed
that for Win64 builds only. Any compiler defining __GNUC__ (clang does) now
takes the intrinsic.

* Compile WinSCP's Windows-only additions to neon on Windows only

WinSCP builds neon for Win32 alone, and three of its additions assume it:
ne_openssl.c includes <windows.h> (it uses nothing from it), timed_connect
switches the socket to non-blocking mode with Winsock's ioctlsocket instead
of upstream's fcntl, and ne_sock_sspi_init calls into SSPI unconditionally.
On POSIX neon uses BSD sockets directly, so the include is guarded with
_WIN32, the two ioctlsocket branches are taken only on _WIN32 (upstream's
fcntl code beside them is used otherwise), and ne_sock_sspi_init calls SSPI
under HAVE_SSPI, as ne_sock_init's own call does, reporting failure (-1)
without it -- which WebDAVFileSystem.cpp already handles as SSPI being
unavailable. C++Builder defines _WIN32 and neon's Win32 config.h defines
HAVE_SSPI, so the Windows build is unchanged.

* Use in_addr's s_addr in FileZilla's proxy layer

AsyncProxySocketLayer.cpp reaches the IPv4 address through Winsock's union,
sin_addr.S_un.S_addr. Winsock also defines s_addr as exactly that member
(#define s_addr S_un.S_addr), and s_addr is the name BSD sockets and POSIX
give the field; a POSIX in_addr has no S_un. Same field, so the Windows
build is unchanged.

* Pass FileZilla's two tool strings as UnicodeString, not std::wstring

CFileZillaTools::GetClientString and CustomReason return std::wstring; the
rest of the interface between core and FileZilla, and both sides' own code,
use UnicodeString or wchar_t pointers. Built with a 2-byte wchar_t on a
platform whose C++ library assumes 4 (clang's -fshort-wchar on Linux),
std::wstring is unusable: libstdc++ provides basic_string<wchar_t> as a
precompiled extern template for its own wchar_t, and char_traits<wchar_t>
calls the C library's 4-byte wcslen and wmemcpy: a Linux build of
FtpFileSystem.cpp imported wcslen through it. The values are only built from
UnicodeString, compared with empty() and read with c_str(), so UnicodeString
is a direct replacement (IsEmpty for empty). On Windows, where wchar_t is 2
bytes throughout, behaviour is unchanged.

* Build storage key paths with backslashes on every platform

THierarchicalStorage joins registry and INI key paths (Sessions\My site)
through its IncludeTrailingBackslash and ExcludeTrailingBackslash members,
which defer to the RTL functions of those names. The RTL's add and strip the
platform's path delimiter: a backslash on Windows, a slash on POSIX, where
these functions also build local file paths. Keys are not file paths: their
separator is a backslash everywhere, and the INI file's sections say so. The
members now add and strip a backslash themselves; on Windows that is what
the RTL did, so the behaviour there is unchanged. Without this, on POSIX the
current key became "Sessions/", matched no section, and no stored site
loaded.

* Hand neon a copy of the TLS-init closure, not its two pointers

SetNeonTlsInit stores the closure in the neon session by reinterpreting it
as a TMethod and saving its code and data pointers, and ne_init_ssl_session
rebuilds it with MakeMethod. That relies on a closure being exactly those
two pointers, which only Borland's __closure is; with any other closure type
the saved words are its internals, read from a by-value parameter that is
gone by the time neon calls back, and the rebuilt closure is garbage (a
clang build's first WebDAV-over-TLS connection crashed there). The session
now holds a heap copy of the closure, freed by neon's destroy-session hook
-- which also covers the sessions libs3 creates and destroys itself -- and
ne_init_ssl_session calls that copy. On C++Builder the behaviour is the
same, at the cost of one small allocation per session.

* Take CString's search results as const wchar_t *

CString::Find, ReverseFind and FindOneOf search the const string c_str()
returns and keep the result in a wchar_t *. ISO C++ declares wcschr,
wcsrchr, wcsstr and wcspbrk on a const string as returning const wchar_t *,
as MSVC's and newer mingw-w64 headers (llvm-mingw's) do, so the
initialisation does not compile there. The pointers are only compared and
subtracted: const is all they need.

* Index the string a string-list property returns, not the property

GetLocales takes a character of Exts->Strings[Index]. Under clang the
__declspec(property) standing for TStrings::Strings' __property reads a
second subscript as the property's own second index, so the expression is a
two-argument call to the getter and does not compile (parentheses do not
change that). Read into a UnicodeString first, the second subscript indexes
the string the property returns, as under C++Builder.

---------

Co-authored-by: Eduardo Correia <ecorreia@apliant.com.br>
2026-10-20 16:01:54 +02:00
Martin Prikryl
c4e2c62171 Using variable as intended
Source commit: d953165a17474e276e54dcc5505ba28867275cf1
2026-05-29 00:51:38 +02:00
Martin Prikryl
a2119a7eac Types and casts safe in respect to pointer size for forward 64-bit compatibility
Also GetWindowLongPtr and GWLP_USERDATA

https://winscp.net/tracker/618

Source commit: c85fdf15e50ce8a6f35b1c4d2a0125a0b9c4f1f0
2026-01-22 14:51:13 +01:00
Martin Prikryl
efe94d6c08 Using actual types and functions instead of WinAPI and Unicode/Ansi macros
Source commit: b7fec4d069296b58bb43e7a4a97dd85d558212b7
2025-12-21 01:34:21 +01:00
Martin Prikryl
e5efed8955 Refactoring old-style casts
Source commit: 3c37b3a958525c595ad44b081b2e0f3b288b8eb0
2025-12-18 01:20:33 +01:00
Martin Prikryl
75acb7dc8a Optimizing synchronization checklist sorting
Source commit: 6e1ae718ba5ba122cea448899377637e6a646d92
2025-11-12 09:26:30 +01:00
Martin Prikryl
0b57612582 Local directories synchronization fails when preview is disabled, some differences are found, but none are selected
Source commit: ac93deb2ec5b4e47359093e1c87adeb63e0f6c83
2025-11-11 01:21:11 +01:00
Martin Prikryl
6094b307b3 Refactoring COM code
Source commit: c04ae4cf541e8c7aae00ee7d7f8818049b808ae6
2025-10-22 18:44:38 +02:00
Martin Prikryl
3cd64f2a19 Issue 2020 – Synchronize two local directories
https://winscp.net/tracker/2020

Source commit: a0ab887a23e4362bb62824434893a97540b24e4a
2025-10-02 22:14:52 +02:00
Martin Prikryl
fa31217b53 Refactoring in anticipation of synchronization not always being local-remote (Issue 2020)
Source commit: 2d05944202efceaff012888c6b0de956314c91b6
2025-10-01 15:30:12 +02:00
Martin Prikryl
a01665f294 Factoring out universal path utility functions that will also be used Issue 2020
Source commit: ecc9f746b50cf7f0203dcb08b1db627375cf5295
2025-10-01 01:19:58 +02:00
Martin Prikryl
34ec281e6d Invalid assertion
Caused by Issue 2370

Source commit: 5313aac260b424eeee78c98040085228416db030
2025-08-29 01:11:26 +02:00
Martin Prikryl
3817bbd736 Preparing for separate pre-compiled header file required by Clang
- Once doing that, including more headers to PCH, not just vcl.h
- Clang won't need explicit include, but we will probably keep it anyway.
- #pragma hdrstop has no effect in Clang

Source commit: adc8a268b6907c5337ccaa430cca7526793a3019
2025-08-22 15:43:55 +02:00
Martin Prikryl
cb09038efd Issue 2370 – Files modified by local custom command are not always uploaded to the correct remote directory
https://winscp.net/tracker/2370

Source commit: c54cd934420ee9c59a0572efd306dfccc83ae78e
2025-05-13 00:58:38 +02:00
Martin Prikryl
8d814d4cc3 Issue 2369 – Failure after switching off Thumbnails view
https://winscp.net/tracker/2369

Source commit: 6ca85570d134d8356b6ea553426e0c9945afae86
2025-04-17 01:01:26 +02:00
Martin Prikryl
94172541ab Unused code
Source commit: 77715db778b119a33d8ac6c3fdfe407f6b22d5b0
2025-04-17 00:58:53 +02:00
Martin Prikryl
7b54dde3a6 Clang identifies some functions as "noreturn" + one noexcept(false)
Source commit: fc0c35fdddcd50a10d9ca13fc515164885325f81
2025-03-14 16:15:03 +01:00
Martin Prikryl
f7f00c631e Clang imposed changes that should be noop and have no effect on classic compiler
Mostly:
– incorrectly identified uninitialized variables
– explicit static global variables
– const, sign and down casts and safety
– typename use
– semicolon after function implementation
– unused variables, fields, arguments and macros
– field initialization order
– exact include filename case
– redundant in code macros already defined at project level

Source commit: 5c1338d95bd275082288dd1e773a033df6e379cd
2025-03-13 16:39:24 +01:00
Martin Prikryl
4dbbc9eb05 Commands to copy paths to the clipboard on the Synchronization checklist window + Bug fix: Local file with invalid characters replaced could not be explorer from the Synchronization checklist window
Source commit: 205edb72d291cca4041e7a8443c37b8749ec27e0
2025-03-07 01:08:03 +01:00
Martin Prikryl
e202af0bdc Issue 2353 – Display and modify S3 file/object tags
https://winscp.net/tracker/2353

Source commit: 2193f9e58d66031ce58013da6a509090582addbe
2025-03-04 15:13:03 +01:00
Michael Lukashov
400bee57cf minor: Fix typos (#59)
Fix various minor typos
2024-12-25 11:25:35 +01:00
Martin Prikryl
cbd7e799df Issue 2318 – Optionally push synchronization actions to queue
https://winscp.net/tracker/2318

Source commit: 8d79009ebeabde5ce762a82d61f36e18c1517d9b
2024-12-23 15:48:13 +01:00
Martin Prikryl
c3aadded64 Factoring out some commons synchronization checklist functions
Source commit: 476fef1cfeea061ec1d35cdb24b2528263eaf247
2024-12-14 01:15:01 +01:00
Martin Prikryl
e40c677e6e Command to find Move candidate on Synchronization checklist window
Source commit: 3afc367ae03df30fa853586a997bfa6fc51ffe53
2024-10-12 01:05:07 +02:00
Mikhail Lukashov
a8e6220b88 fix typos 2024-01-05 10:37:32 +01:00
Martin Prikryl
59393658a0 Bug 2227: Restored ability to duplicate remote folders using "cp" command in secondary shell session even when the SFTP server supports copy-file/copy-data extension
https://winscp.net/tracker/2227

Source commit: 9a0ccf0972df5275cdf7409a6e6d0d1e283a8210
2023-10-04 01:16:01 +02:00
Martin Prikryl
266b470cf8 Using tolower and towupper
Source commit: 9679e092efa1a4683538eb9b46374f90b5699ab3
2023-08-19 01:13:29 +02:00
Martin Prikryl
1aee6f1464 Bug 513: Download single large file using multiple SFTP connections
https://winscp.net/tracker/513

Source commit: d57dcad76dfe8b333dfedd8419bce984a181280c
2023-07-27 01:02:51 +02:00
Martin Prikryl
247565d23b Optimization in anticipation of having to parse commandline URL one more time
Source commit: bf2531704d0091b8015811da8ef58374c7516d71
2023-07-01 01:03:57 +02:00
Martin Prikryl
5b57c3b878 Using the same timestamp format in local and remote file panels
Source commit: 4690f559201ff1c23b38abe043ddae381959c071
2023-03-03 00:59:59 +01:00
Martin Prikryl
d284d93a83 Merge branch 'master' into dev
# Conflicts:
#	source/forms/ScpCommander.cpp

#	source/windows/WinConfiguration.h

Source commit: 6303fe6c4c5929ade1127007af6321e256f6940d
2022-03-30 01:23:44 +02:00
Martin Prikryl
191729720a Bug 2065 – Scripting command "ls" in FTP session displays timestamps without year even if the server (notably IIS) provided the year, if it did not provide seconds
https://winscp.net/tracker/2065

Source commit: 4d719f707f54a5ce7d1ff2ad327a1159ccb3fefe
2022-03-26 01:07:27 +01:00
Martin Prikryl
eb4ab603f3 Grammar in a comment
Source commit: 9e373d5219c8829c2a49892a527a57310d98c352
2022-03-26 01:05:12 +01:00
Martin Prikryl
958a9949c6 Bug 2052: File masks relative to the root of an operation
https://winscp.net/tracker/2052
(cherry picked from commit c5a60526ed)

Source commit: d1db6dd6b43b56565709801383e235ce4c6a1005
2021-12-15 01:11:42 +01:00
Martin Prikryl
c5a60526ed Bug 2052: File masks relative to the root of an operation
https://winscp.net/tracker/2052

Source commit: 6c037285152e369af4f530849a09848f0b9be880
2021-12-15 01:01:06 +01:00
Martin Prikryl
d2f9693f1c Bug 1641: Support ACL for S3
https://winscp.net/tracker/1641
(cherry picked from commit 9b304c1b32)

# Conflicts:
#	source/forms/CustomScpExplorer.h

Source commit: bf3c1b88326df1dc340f6ca06f93953db7c82c27
2021-11-26 14:59:21 +01:00
Martin Prikryl
d10d0f530f Hiding irrelevant controls on Properties dialog
(also removing some small refactoring in LoadInfo)

(cherry picked from commit ef9d22f377)

Source commit: 2dc3a7971103359941899f0b838f9ce193e49156
2021-11-26 13:59:23 +01:00
Martin Prikryl
2d3d6f0479 Dropping no-longer working and never-documented LockInHome feature
(cherry picked from commit 42a30f9e94)

# Conflicts:
#	source/core/SessionData.h

Source commit: f0ebedce16593c0c69a854d8ef0539adbfbf52e2
2021-11-25 16:33:00 +01:00
Martin Prikryl
2d82990a1e Typo in a comment
(cherry picked from commit d69141984a)

Source commit: 61b568ba5b186d396b308b8cf1aff7643ab5b650
2021-11-25 15:46:48 +01:00
Martin Prikryl
bdcdc791ba Reusing function
(cherry picked from commit 79184b3fe6)

Source commit: ad84c82db4ea97d2ddd65f0237741c0a1eb12b06
2021-11-23 16:00:55 +01:00
Martin Prikryl
4ffc5d3f88 Reusing constant
(cherry picked from commit f91e800402)

Source commit: 37f231decd965ce798b441e443a5cb4c1fa3ad9c
2021-11-23 15:58:18 +01:00
Martin Prikryl
9b304c1b32 Bug 1641: Support ACL for S3
https://winscp.net/tracker/1641

Source commit: 03a0b16e1a553b6a2791a2276e94a4547ab3451f
2021-11-05 11:15:56 +01:00
Martin Prikryl
ef9d22f377 Hiding irrelevant controls on Properties dialog
(also removing some small refactoring in LoadInfo)

Source commit: 34c70ad80b2dc77448ed447e6458d0957a52afb6
2021-10-06 00:48:20 +02:00
Martin Prikryl
42a30f9e94 Dropping no-longer working and never-documented LockInHome feature
Source commit: bc360b54365994cbcfaac592d766fe52ae4f1dc8
2021-07-28 01:01:12 +02:00
Martin Prikryl
d69141984a Typo in a comment
Source commit: 0329c66ae7a9c89dc3eca733f595d900a436716a
2021-07-12 00:47:12 +02:00
Martin Prikryl
bfe5b292e9 Bug 41: Show directory size in file panel
https://winscp.net/tracker/41

Source commit: 65720b4a0c4b3ff88c4b0c116de9f2b13f57480a
2021-05-12 00:57:43 +02:00
Martin Prikryl
79184b3fe6 Reusing function
Source commit: db5176812916bbbbe7bbdec8ac506b96b5437b5b
2021-05-04 10:53:20 +02:00
Martin Prikryl
f91e800402 Reusing constant
Source commit: de4f5018fd7b6190f9a67c9c2261a11e66621474
2021-05-04 10:51:28 +02:00
Martin Prikryl
98527fe824 Bug 1850: Support clearing GID/UID flag on directories with new versions of GNU coreutils
https://winscp.net/tracker/1850
(cherry picked from commit e31f0b66c7)

Source commit: cd1683ffc98036433af968f26191c562d3db7062
2020-11-26 11:26:34 +01:00
Martin Prikryl
7c0121b5d9 Bug 1893: Basic implementation of local tabs
Source commit: fc01f97bd46c7581fcd9c9ebd5f45c345e50a0d6
2020-11-20 00:45:16 +01:00