Windows API to access case-sensitive paths (Bash-on-Ubuntu-on-Windows)

泪湿孤枕 提交于 2019-12-04 13:17:10
tmr232

Case-sensitive paths can be used on Windows with NTFS, but it requires a bit of extra work.

First, case-sensitivity must be enabled system-wide. This is done by setting the HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\ dword:ObCaseInsensitive registry value to 0, then restarting the system. I found this part here.

Once case-sensitivity is enabled, it is possible to use CreateFile to with case-sensitive paths. To do that, you have to pass the FILE_FLAG_POSIX_SEMANTICS as part of the dwFlagsAndAttributes parameter. From msdn:

Access will occur according to POSIX rules. This includes allowing multiple files with names, differing only in case, for file systems that support that naming.

I found this part in this answer.

By setting the registry setting and the CreateFile flag, I was able to access case-sensitive paths.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!