[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why exception from os.path.exists()?

On Mon, 04 Jun 2018 13:33:28 +0100, Paul Moore wrote:

> But there's also the question of what capability the kernel API has to
> express the queries. The fact that the Unix API (and the Windows one, in
> most cases - although as Eryk Sun pointed out there are exceptions in
> the Windows kernel API) uses NUL-terminated strings means that querying
> the filesystem about filenames with embedded \0 characters isn't
> possible *at the OS level*.

I don't know whether or not the Linux OS is capable of accessing files 
with embedded NULs in the file name. But Mac OS is capable of doing so, 
so it should be possible. Wikipedia says:

"HFS Plus mandates support for an escape sequence to allow arbitrary 
Unicode. Users of older software might see the escape sequences instead 
of the desired characters."

Apple File System is an even more modern FS (it replaced HFS Plus in 2017 
as Apple's preferred OS) which supports all Unicode code points, 
including NUL.

Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson