@@ -548,37 +548,35 @@ struct sysres_type {
548
548
argptr_type argptr{};
549
549
};
550
550
551
+ /* We make a path from a C string...
552
+ In an array, in a dictionary...
553
+ Without type safety...
554
+ Because most of darwin's apis are `void*`-typed.
555
+
556
+ We should be guarenteed that nothing in here is
557
+ or can be null, but I'm skeptical. We ask Darwin
558
+ for utf8 strings from a dictionary of utf8 strings
559
+ which it gave us. Nothing should be able to be null.
560
+ We'll check anyway, just in case Darwin lies.
561
+
562
+ The dictionary contains looks like this:
563
+ { "path": String
564
+ , "fileID": Number
565
+ }
566
+ We can only call `CFStringGetCStringPtr()`
567
+ on the `path` field. Not sure what function
568
+ the `fileID` requires, or if it's different
569
+ from what we'd get from `stat()`. (Is it an
570
+ inode number?) Anyway, we seem to get this:
571
+ -[__NSCFNumber length]: unrecognized ...
572
+ Whenever we try to inspect it with Int or
573
+ CStringPtr functions for CFStringGet...().
574
+ The docs don't say much about these fields.
575
+ I don't think they mention fileID at all.
576
+ */
551
577
inline auto path_from_event_at (void * event_recv_paths, unsigned long i) noexcept
552
578
-> std::filesystem::path
553
579
{
554
- /* We make a path from a C string...
555
- In an array, in a dictionary...
556
- Without type safety...
557
- Because most of darwin's apis are `void*`-typed.
558
-
559
- We should be guarenteed that nothing in here is
560
- or can be null, but I'm skeptical. We ask Darwin
561
- for utf8 strings from a dictionary of utf8 strings
562
- which it gave us. Nothing should be able to be null.
563
- We'll check anyway, just in case Darwin lies.
564
-
565
- The dictionary contains looks like this:
566
- { "path": String
567
- , "fileID": Number
568
- }
569
- We can only call `CFStringGetCStringPtr()`
570
- on the `path` field. Not sure what function
571
- the `fileID` requires, or if it's different
572
- from what we'd get from `stat()`. (Is it an
573
- inode number?) Anyway, we seem to get this:
574
- -[__NSCFNumber length]: unrecognized ...
575
- Whenever we try to inspect it with Int or
576
- CStringPtr functions for CFStringGet...().
577
- The docs don't say much about these fields.
578
- I don't think they mention fileID at all.
579
- */
580
- namespace fs = std::filesystem;
581
-
582
580
if (event_recv_paths)
583
581
if (
584
582
void const * from_arr = CFArrayGetValueAtIndex (
@@ -592,8 +590,9 @@ inline auto path_from_event_at(void* event_recv_paths, unsigned long i) noexcept
592
590
char const * as_cstr = CFStringGetCStringPtr (
593
591
static_cast <CFStringRef>(from_dict),
594
592
kCFStringEncodingUTF8 ))
595
- return fs::path{as_cstr};
596
- return fs::path{};
593
+ return {as_cstr};
594
+
595
+ return {};
597
596
}
598
597
599
598
inline auto event_recv_one (
@@ -604,12 +603,13 @@ inline auto event_recv_one(
604
603
using path_type = enum ::wtr::watcher::event::path_type;
605
604
using effect_type = enum ::wtr::watcher::event::effect_type;
606
605
607
- if (
608
- ! ctx // These checks are unfortunate
609
- || ! ctx->callback // and absolutely necessary.
610
- || ! ctx->seen_created_paths // Once in a while, Darwin will only
611
- || ! ctx->last_rename_from_path // give *part* of the context to us.
612
- ) [[unlikely]]
606
+ auto ctx_ok =
607
+ ctx // These checks are unfortunate
608
+ && ctx->callback // and absolutely necessary.
609
+ && ctx->seen_created_paths // Once in a while, Darwin will only
610
+ && ctx->last_rename_from_path ; // give *part* of the context to us.
611
+
612
+ if (! ctx_ok) [[unlikely]]
613
613
return ;
614
614
615
615
auto [callback, sc_paths, lrf_path] = *ctx;
0 commit comments