Closed atishay closed 1 month ago
While I don't doubt that this is a bug (and we'll fix it), I'm very curious the story behind how you stumbled across it.
Should be fixed around here: https://github.com/e-dant/watcher/commit/d9d9d8ba0d8019cf9ab1b90f9139e3630b1b9f22#diff-5e556a082ae9130c476cd18ad3e9e7fba7ca7ff2b18810917c7550e1964ce84eL101-R107 and https://github.com/e-dant/watcher/commit/d9d9d8ba0d8019cf9ab1b90f9139e3630b1b9f22#diff-5e556a082ae9130c476cd18ad3e9e7fba7ca7ff2b18810917c7550e1964ce84eL29-R30
Thank you
Problem
The file path in the watch event is coming out to be null for certain file operations on macOS.
Details
The API used in the code https://github.com/e-dant/watcher/blob/release/devel/include/detail/wtr/watcher/adapter/darwin/watch.hpp#L114 is
CFStringGetCStringPtr
The official documentation clearly states that this method may return null if the internal implementation in macOS cannot provide a no allocation pointer and should not be relied on.
https://developer.apple.com/documentation/corefoundation/1542133-cfstringgetcstringptr?language=objc
Alternate function that works for me: