curl-curl/docs/internals
Viktor Szakats 6d0ee7b17b
curlx: add curlx_rename(), fix to support long filenames on Windows
Move existing `Curl_rename()` `rename()` wrapper from lib to
curlx/fopen, and make it a curlx macro/function. To allow using
the local worker function to fixup long filenames on Windows.

Then fix the Windows-specific rename implementation to support long
filenames. This operation may happen when using a cookie jar, HSTS cache
or alt-svc cache, via libcurl or the curl tool.

Before this patch, when passing a long filename to the above options,
a `<random>.tmp` file was left on the disk without renaming it to the
filename passed to curl. There was also 1 second delay for each
attempted rename operation.

Also:
- checksrc: ban raw `rename()` and `MoveFileEx*()` functions.
- Note: `Curl_rename()` returned 1 on failure before this patch, while
  `curlx_rename()` returns -1 after, to match POSIX `rename()`.

Refs:
https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-movefileexa
https://learn.microsoft.com/windows/win32/fileio/maximum-file-path-limitation

Ref: #20040

Closes #20042
2025-12-20 16:03:11 +01:00
..
BUFQ.md docs: fold long lines 2025-12-11 11:42:28 +01:00
BUFREF.md bufref: add Curl_bufref_dup that returns a strdup()ed version 2025-12-04 19:04:19 +01:00
CHECKSRC.md build: stop overriding standard memory allocation functions 2025-11-28 10:44:26 +01:00
CLIENT-READERS.md docs: fold long lines 2025-12-11 11:42:28 +01:00
CLIENT-WRITERS.md docs: fold long lines 2025-12-11 11:42:28 +01:00
CODE_STYLE.md curlx: add curlx_rename(), fix to support long filenames on Windows 2025-12-20 16:03:11 +01:00
CONNECTION-FILTERS.md docs: fold long lines 2025-12-11 11:42:28 +01:00
CURLX.md
DYNBUF.md
HASH.md
LLIST.md
MID.md
MQTT.md docs: fold long lines 2025-12-11 11:42:28 +01:00
MULTI-EV.md
NEW-PROTOCOL.md
PORTING.md
RATELIMITS.md ratelimit: redesign 2025-11-24 23:34:05 +01:00
README.md
SCORECARD.md docs: fold long lines 2025-12-11 11:42:28 +01:00
SPLAY.md
STRPARSE.md
TIME-KEEPING.md TIME-KEEPING.md: fold long lines 2025-12-18 23:00:06 +01:00
TLS-SESSIONS.md docs: fold long lines 2025-12-11 11:42:28 +01:00
UINT_SETS.md TIME-KEEPING.md: fold long lines 2025-12-18 23:00:06 +01:00
WEBSOCKET.md

Internals

This directory contains documentation covering libcurl internals; APIs and concepts that are useful for contributors and maintainers.

Public APIs are documented in the public documentation, not here.