Skip to content

System: read the attributes of a file on Windows, for OpenFL's File.isHidden - #2120

Open
Tutez64 wants to merge 1 commit into
openfl:developfrom
Tutez64:feature/system-windows-file-attributes
Open

Tutez64 wants to merge 1 commit into
openfl:developfrom
Tutez64:feature/system-windows-file-attributes

Conversation

@Tutez64

@Tutez64 Tutez64 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

OpenFL's File.isHidden runs attrib in a new process for each call on
Windows, about 30 ms each on an idle machine. Its TODO says this should come
from Lime instead.

This adds lime_system_get_windows_file_attributes(path), for CFFI and
HashLink. It returns the FILE_ATTRIBUTE_* flags of a file or directory from
GetFileAttributesW, or -1 if there is no such path or this is not Windows.
System.__getWindowsFileAttributes wraps it for OpenFL, as __getDirectory
does for its directories. The path goes to Windows in UTF-16: from
hxs_wchar on CFFI, and as the string's own bytes on HashLink.

Test: system.WindowsFileAttributesTest writes a file and checks that it has
attributes but is not hidden, is hidden after attrib +h, and has none once
deleted. On cpp, the file name has a non-ASCII character. Neko's files take
their names in the ANSI code page, so there the name is ASCII. Elsewhere, the
test checks that the function returns -1.

It passes on a Windows VM in lime test windows (MSVC) and lime test neko,
on a Lime build with this change, and on Linux in lime test linux and
lime test neko. HashLink was not run locally.

…sHidden

Adds lime_system_get_windows_file_attributes, for CFFI and HashLink, which
returns the FILE_ATTRIBUTE_* flags of a path from GetFileAttributesW, or -1 if
there is no such file or this is not Windows. OpenFL's File.isHidden ran
attrib in a new process for each call, which its TODO meant Lime to replace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant