Define WFSEEK_SUCCESS() for instances where WFSEEK() returns non-zero success case

pull/1157/head
Ruby Martin 2026-08-05 17:18:09 -06:00 committed by John Safranek
parent e52fbd1f2c
commit bf5a8015e2
1 changed files with 11 additions and 0 deletions

View File

@ -124,6 +124,7 @@ extern "C" {
#define WREWIND(fs,s) NU_Seek(*(s), 0, PSEEK_SET)
#define WSEEK_END PSEEK_END
#define WBADFILE NULL
#define WFSEEK_SUCCESS(r) ((int)(r) >= 0)
#define WS_DELIM '\\'
#define WOLFSSH_O_RDWR PO_RDWR
@ -440,6 +441,7 @@ extern "C" {
#define WSETTIME(fs,f,a,m) (0)
#define WFSETTIME(fs,fd,a,m) (0)
#define WCHDIR(fs,b) SYS_FS_DirectryChange((b))
#define WFSEEK_SUCCESS(r) ((int)(r) >= 0)
#else
#include <stdlib.h>
@ -1624,6 +1626,15 @@ extern "C" {
#define WOLFSSH_O_NOFOLLOW 0
#endif
/* Catch-all so callers can test a seek result unconditionally. Ports whose
* seek returns the new file position rather than a 0/-1 status define their
* own WFSEEK_SUCCESS() in the port block above; see Nucleus and MPLAB
* Harmony. Any definition must evaluate its argument exactly once, as
* callers pass the WFSEEK() call in directly. */
#ifndef WFSEEK_SUCCESS
#define WFSEEK_SUCCESS(r) ((r) == 0)
#endif
/* wIsSymlink lives in the always-compiled port.c, but its filesystem
* dependencies (WSTAT_T/WLSTAT/S_ISLNK on POSIX, WS_GetFileAttributesExA on
* Windows) and its only callers exist solely in the SFTP and SCP code, so