Skip to content

fix(sqlite-objstore): provide win32 dirent shim so MSVC builds compile - #22

Merged
gabewillen merged 1 commit into
mainfrom
fix/sqlite-objstore-win32-dirent
Aug 17, 2026
Merged

fix(sqlite-objstore): provide win32 dirent shim so MSVC builds compile#22
gabewillen merged 1 commit into
mainfrom
fix/sqlite-objstore-win32-dirent

Conversation

@gabewillen

Copy link
Copy Markdown
Contributor

The npm release pipeline for @augmem/cortext v1.3.3 builds all six N-API
addons from this exact tag. Both Windows matrix jobs (win32-x64 on MSVC,
win32-arm64 on clang-cl) fail with:

third_party/sqlite-objstore/src/backend_fs_common.c(3,10):
error C1083: Cannot open include file: 'dirent.h'

The objstore file backends use only opendir/readdir (d_name only)/
closedir, which does not exist on Windows. This adds a minimal vendored
win32 shim (FindFirstFileA/FindNextFileA/FindClose) selected via a
_WIN32 include guard in the three affected files, plus a WIN32 guard in
both CMake source lists (subproject and top-level embedded list).

Verified: object-level cross-compilation of all four translation units for
x86_64-windows-gnu and aarch64-windows-gnu via zig (same _WIN32 code
path as MSVC/clang-cl; zig on this host has no MSVC sysroot), zero
-pedantic warnings; native macOS arm64 objstore suite 4/4 ctest,
80/80 unit tests, warnings-as-errors clean.

Copilot AI lite review requested due to automatic review settings August 17, 2026 04:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to unblock Windows (MSVC / clang-cl) builds of the vendored sqlite-objstore dependency by removing the hard dependency on <dirent.h> and introducing a minimal Win32 replacement used by the filesystem backends.

Changes:

  • Add a minimal Win32 opendir/readdir/closedir shim (win_dirent.{h,c}) for sqlite-objstore.
  • Switch the affected objstore backends to include the shim on _WIN32 instead of <dirent.h>.
  • Update both the objstore subproject CMake and the top-level embedded-source list to compile win_dirent.c on WIN32.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
third_party/sqlite-objstore/src/win_dirent.h Introduces a minimal dirent/DIR API surface for Windows builds.
third_party/sqlite-objstore/src/win_dirent.c Implements opendir/readdir/closedir using Win32 file enumeration APIs.
third_party/sqlite-objstore/src/CMakeLists.txt Adds win_dirent.c to objstore sources when building on Windows.
third_party/sqlite-objstore/src/backend_portable.c Uses win_dirent.h on _WIN32 instead of <dirent.h>.
third_party/sqlite-objstore/src/backend_fs_common.c Uses win_dirent.h on _WIN32 instead of <dirent.h>.
third_party/sqlite-objstore/src/backend_file.c Uses win_dirent.h on _WIN32 instead of <dirent.h>.
CMakeLists.txt Ensures embedded objstore builds compile win_dirent.c on Windows.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +30 to +41
handle = FindFirstFileA (path, &find_data);
if (handle == INVALID_HANDLE_VALUE)
{
free (dir);
errno = ENOENT;
return NULL;
}

dir->handle = (void *) handle;
memcpy (dir->entry.d_name, find_data.cFileName,
sizeof (find_data.cFileName));
dir->entry_valid = 1;
Comment on lines +67 to +69
memcpy (dir->entry.d_name, find_data.cFileName,
sizeof (find_data.cFileName));
dir->entry_valid = 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants