sys_full_path on Windows copies only half of each path part's case on disk

Open Beginner friendly
#1,026 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@dimensionscape is already working on this.

Since Nov 22, 2026.

  • #1027 by @dimensionscape — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

The bug is in hl_sys_full_path in src/std/sys.c, where the memcpy(out + last, data.cFileName, i - last) call around line 643 copies a count of characters as bytes. Read the surrounding FindFirstFileW loop, then change the length to (i - last) * sizeof(pchar). Done when the Windows reproduction in the issue, creating FullPathCase and calling fullPath on fullpathcase, returns the on-disk casing for every character.

Written by the indexing model from the issue text.

Description

On Windows, sys.FileSystem.fullPath() (hl_sys_full_path in src/std/sys.c) looks up each part of the path with FindFirstFileW to give it the case it has on disk. It then copies the name found back into the path with:

memcpy(out + last, data.cFileName, i - last);

out and data.cFileName are wide strings (pchar / WCHAR), but i - last counts characters, and memcpy takes bytes. So only the first half of each part gets its case on disk, and the rest keeps the case it was given.

Steps to reproduce, on Windows:

class Main {
	static function main() {
		var base = sys.FileSystem.fullPath(Sys.getEnv("TEMP"));
		sys.FileSystem.createDirectory(base + "\\FullPathCase");
		trace(sys.FileSystem.fullPath(base + "\\fullpathcase"));
		sys.FileSystem.deleteDirectory(base + "\\FullPathCase");
	}
}

Expected: ...\FullPathCase
Got: ...\FullPathcase. Only the first 6 of the 12 characters (12 bytes) take their case on disk, and thcase keeps the case it was given.

Fix: copy (i - last) * sizeof(pchar) bytes:

memcpy(out + last, data.cFileName, (i - last) * sizeof(pchar));

This is still in master (sys.c line 643 at the time of writing). We found it in Lime, which builds HashLink's runtime from source, through a test that compares the folder name fullPath gives with the name on disk.

Dominant language
C
Stars
911
Forks
207
Avg merge
1d 21h
Merged PRs (30d)
13

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HaxeFoundation/hashlink

All issues in HaxeFoundation/hashlink

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.