cidre 0.9.2

Apple frameworks bindings for rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
use crate::{arc, define_cls, define_obj_type, define_opts, ns, objc, os};

#[cfg(feature = "blocks")]
use crate::blocks;

define_obj_type!(
    #[doc(alias = "NSFileAttributeKey")]
    pub FileAttrKey(ns::String)
);

define_obj_type!(
    #[doc(alias = "NSFileAttributeType")]
    pub FileAttrType(ns::String)
);

define_obj_type!(
    #[doc(alias = "NSFileProtectionType")]
    pub FileProtectionType(ns::String)
);

define_opts!(
    #[doc(alias = "NSVolumeEnumerationOptions")]
    pub VolumeEnumOpts(usize)
);

impl VolumeEnumOpts {
    ///  The mounted volume enumeration will skip hidden volumes.
    #[doc(alias = "NSVolumeEnumerationSkipHiddenVolumes")]
    pub const SKIP_HIDDEN_VOLUMES: Self = Self(1 << 1);

    /// The mounted volume enumeration will produce file reference URLs rather than path-based URLs.
    #[doc(alias = "NSVolumeEnumerationProduceFileReferenceURLs")]
    pub const PRODUCE_FILE_REFERENCE_URLS: Self = Self(1 << 2);
}

define_opts!(
    #[doc(alias = "NSDirectoryEnumerationOptions")]
    pub DirEnumOpts(usize)
);

impl DirEnumOpts {
    /// Causes the to perform a shallow enumeration and not descend into directories it encounters.
    #[doc(alias = "NSDirectoryEnumerationSkipsSubdirectoryDescendants")]
    pub const SKIPS_SUBDIRECTORY_DESCENDANTS: Self = Self(1 << 0);

    /// Will cause the to not descend into packages.
    #[doc(alias = "NSDirectoryEnumerationSkipsPackageDescendants")]
    pub const SKIPS_PACKAGE_DESCENDANTS: Self = Self(1 << 1);

    /// Causes the to not enumerate hidden files.
    #[doc(alias = "NSDirectoryEnumerationSkipsHiddenFiles")]
    pub const SKIPS_HIDDEN_FILES: Self = Self(1 << 2);

    /// Causes the to enumerate each directory a second time after all of its contained files have been enumerated.
    /// Use isEnumeratingDirectoryPostOrder to differentiate a post-order enumerated directory from a pre-order one.
    #[doc(alias = "NSDirectoryEnumerationIncludesDirectoriesPostOrder")]
    pub const INCLUDES_DIRECTORIES_POST_ORDER: Self = Self(1 << 3);

    /// Causes the to always produce file path URLs relative to the directoryURL. This can reduce the size of each URL object returned during enumeration.
    #[doc(alias = "NSDirectoryEnumerationProducesRelativePathURLs")]
    pub const PRODUCES_RELATIVE_PATH_URLS: Self = Self(1 << 4);
}

define_opts!(
    #[doc(alias = "NSFileManagerItemReplacementOptions")]
    pub ItemReplacementOpts(usize)
);

impl ItemReplacementOpts {
    #[doc(alias = "NSFileManagerItemReplacementUsingNewMetadataOnly")]
    pub const USING_NEW_METADATA_ONLY: Self = Self(1 << 0);

    #[doc(alias = "NSFileManagerItemReplacementWithoutDeletingBackupItem")]
    pub const WITHOUT_DELETING_BACKUP_ITEM: Self = Self(1 << 1);
}

#[doc(alias = "NSURLRelationship")]
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
#[repr(isize)]
pub enum UrlRelationship {
    #[doc(alias = "NSURLRelationshipContains")]
    Contains,

    #[doc(alias = "NSURLRelationshipSame")]
    Same,

    #[doc(alias = "NSURLRelationshipOther")]
    Other,
}

define_opts!(
    #[doc(alias = "NSFileManagerUnmountOptions")]
    pub UnmountOpts(usize)
);

impl UnmountOpts {
    #[doc(alias = "NSFileManagerUnmountAllPartitionsAndEjectDisk")]
    pub const ALL_PARTITIONS_AND_EJECT_DISK: Self = Self(1 << 0);

    #[doc(alias = "NSFileManagerUnmountWithoutUI")]
    pub const WITHOUT_UI: Self = Self(1 << 1);
}

define_obj_type!(
    #[doc(alias = "NSFileManager")]
    pub FileManager(ns::Id)
);

impl FileManager {
    define_cls!(NS_FILE_MANAGER);

    #[objc::msg_send(defaultManager)]
    pub fn default() -> arc::R<FileManager>;

    #[objc::msg_send(contentsOfDirectoryAtURL:includingPropertiesForKeys:options:error:)]
    pub unsafe fn contents_of_dir_at_url_err<'ear>(
        &self,
        url: &ns::Url,
        including_props_for_keys: Option<&ns::Array<ns::UrlResKey>>,
        options: DirEnumOpts,
        error: *mut Option<&'ear ns::Error>,
    ) -> Option<arc::R<ns::Array<ns::Url>>>;

    pub fn contents_of_dir_at_url<'ear>(
        &self,
        url: &ns::Url,
        including_props_for_keys: Option<&ns::Array<ns::UrlResKey>>,
        options: DirEnumOpts,
    ) -> Result<arc::R<ns::Array<ns::Url>>, &'ear ns::Error> {
        ns::if_none(|err| unsafe {
            self.contents_of_dir_at_url_err(url, including_props_for_keys, options, err)
        })
    }

    #[objc::msg_send(URLForDirectory:inDomain:appropriateForURL:create:error:)]
    pub unsafe fn url_for_dir_err<'ear>(
        &self,
        directory: ns::SearchPathDirectory,
        in_domain: ns::SearchPathDomainMask,
        appropriate_for_url: Option<&ns::Url>,
        create: bool,
        error: *mut Option<&'ear ns::Error>,
    ) -> Option<arc::R<ns::Url>>;

    pub fn url_for_dir<'ear>(
        &self,
        directory: ns::SearchPathDirectory,
        in_domain: ns::SearchPathDomainMask,
        appropriate_for_url: Option<&ns::Url>,
        create: bool,
    ) -> Result<arc::R<ns::Url>, Option<&'ear ns::Error>> {
        let mut error = None;
        if let Some(res) = unsafe {
            self.url_for_dir_err(
                directory,
                in_domain,
                appropriate_for_url,
                create,
                &mut error,
            )
        } {
            Ok(res)
        } else {
            Err(error)
        }
    }

    #[objc::msg_send(createDirectoryAtURL:withIntermediateDirectories:attributes:error:)]
    pub unsafe fn create_dir_at_url_err<'ear>(
        &self,
        url: &ns::Url,
        create_intermediates: bool,
        attributes: Option<&ns::Dictionary<ns::FileAttrKey, ns::Id>>,
        error: *mut Option<&'ear ns::Error>,
    ) -> bool;

    pub fn create_dir_at_url<'ear>(
        &self,
        url: &ns::Url,
        create_intermediates: bool,
        attributes: Option<&ns::Dictionary<ns::FileAttrKey, ns::Id>>,
    ) -> ns::Result {
        ns::if_false(|err| unsafe {
            self.create_dir_at_url_err(url, create_intermediates, attributes, err)
        })
    }

    #[objc::msg_send(createDirectoryAtPath:withIntermediateDirectories:attributes:error:)]
    pub unsafe fn create_dir_at_path_err<'ear>(
        &self,
        path: &ns::String,
        create_intermediates: bool,
        attributes: Option<&ns::Dictionary<ns::FileAttrKey, ns::Id>>,
        error: *mut Option<&'ear ns::Error>,
    ) -> bool;

    #[inline]
    pub fn create_dir_at_path<'ear>(
        &self,
        path: &ns::String,
        create_intermediates: bool,
        attributes: Option<&ns::Dictionary<ns::FileAttrKey, ns::Id>>,
    ) -> ns::Result {
        ns::if_false(|err| unsafe {
            self.create_dir_at_path_err(path, create_intermediates, attributes, err)
        })
    }

    #[objc::msg_send(removeItemAtPath:error:)]
    pub unsafe fn remove_item_at_path_err<'ear>(
        &self,
        path: &ns::String,
        error: *mut Option<&'ear ns::Error>,
    ) -> bool;

    #[inline]
    pub fn remove_item_at_path<'ear>(&self, path: &ns::String) -> ns::Result {
        ns::if_false(|err| unsafe { self.remove_item_at_path_err(path, err) })
    }

    #[objc::msg_send(currentDirectoryPath)]
    pub fn current_dir_path(&self) -> arc::R<ns::String>;

    #[objc::msg_send(changeCurrentDirectoryPath:)]
    pub fn change_current_dir_path(&mut self, path: &ns::String) -> bool;

    #[objc::msg_send(fileExistsAtPath:)]
    pub fn file_exists_at_path(&self, path: &ns::String) -> bool;

    #[objc::msg_send(fileExistsAtPath:isDirectory:)]
    pub fn file_exists_at_path_is_dir(&self, path: &ns::String, is_dir: &mut bool) -> bool;

    #[objc::msg_send(isReadableFileAtPath:)]
    pub fn is_readable_file_at_path(&self, path: &ns::String) -> bool;

    #[objc::msg_send(isWritableFileAtPath:)]
    pub fn is_writable_file_at_path(&self, path: &ns::String) -> bool;

    #[objc::msg_send(isExecutableFileAtPath:)]
    pub fn is_executable_file_at_path(&self, path: &ns::String) -> bool;

    #[objc::msg_send(isDeletableFileAtPath:)]
    pub fn is_deletable_file_at_path(&self, path: &ns::String) -> bool;

    #[objc::msg_send(setUbiquitous:itemAtURL:destinationURL:error:)]
    pub unsafe fn set_ubiquitous_item_err<'ar>(
        &mut self,
        value: bool,
        item_at_url: &ns::Url,
        dest_url: &ns::Url,
        error: *mut Option<&'ar ns::Error>,
    ) -> bool;

    #[inline]
    pub fn set_ubiquitous_item<'ear>(
        &mut self,
        value: bool,
        item_at_url: &ns::Url,
        dest_url: &ns::Url,
    ) -> ns::Result<'ear> {
        ns::if_false(|err| unsafe {
            self.set_ubiquitous_item_err(value, item_at_url, dest_url, err)
        })
    }

    #[objc::msg_send(isUbiquitousItemAtURL:)]
    pub fn is_ubiquitous_item(&self, item_at_url: &ns::Url) -> bool;

    #[objc::msg_send(startDownloadingUbiquitousItemAtURL:error:)]
    pub fn start_downloading_ubquitous_item_err<'ar>(
        &mut self,
        item_at_url: &ns::Url,
        error: *mut Option<&'ar ns::Error>,
    ) -> bool;

    pub fn start_downloading_ubquitous_item<'ear>(
        &mut self,
        item_at_url: &ns::Url,
    ) -> ns::Result<'ear> {
        ns::if_false(|err| self.start_downloading_ubquitous_item_err(item_at_url, err))
    }

    #[objc::msg_send(evictUbiquitousItemAtURL:error:)]
    pub fn evict_ubiquitous_item_err<'ar>(
        &mut self,
        item_at_url: &ns::Url,
        error: *mut Option<&'ar ns::Error>,
    ) -> bool;

    #[inline]
    pub fn evict_ubiquitous_item<'ear>(&mut self, item_at_url: &ns::Url) -> ns::Result<'ear> {
        ns::if_false(|err| self.evict_ubiquitous_item_err(item_at_url, err))
    }

    #[cfg(target_os = "macos")]
    #[objc::msg_send(mountedVolumeURLsIncludingResourceValuesForKeys:options:)]
    pub fn mounted_volume_urls(
        &self,
        keys: Option<&ns::Array<ns::UrlResKey>>,
        options: ns::VolumeEnumOpts,
    ) -> arc::R<ns::Array<ns::Url>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(unmountVolumeAtURL:options:completionHandler:)]
    pub fn unmount_volume_at_url_ch_block(
        &self,
        url: &ns::Url,
        options: ns::FileManagerUnmountOpts,
        ch: &mut blocks::ErrCh,
    );

    #[cfg(feature = "blocks")]
    #[inline]
    pub fn unmount_volume_at_url_ch(
        &self,
        url: &ns::Url,
        options: ns::FileManagerUnmountOpts,
        ch: impl FnMut(Option<&ns::Error>) + 'static,
    ) {
        let mut ch = blocks::ErrCh::new1(ch);
        self.unmount_volume_at_url_ch_block(url, options, &mut ch)
    }

    #[cfg(all(feature = "blocks", feature = "async"))]
    #[inline]
    pub async fn unmount_volume_at_url(
        &self,
        url: &ns::Url,
        options: ns::FileManagerUnmountOpts,
    ) -> Result<(), arc::R<ns::Error>> {
        let (future, mut ch) = blocks::ok();
        self.unmount_volume_at_url_ch_block(url, options, &mut ch);
        future.await
    }
}

#[link(name = "ns", kind = "static")]
unsafe extern "C" {
    static NS_FILE_MANAGER: &'static objc::Class<FileManager>;
}

#[link(name = "Foundation", kind = "framework")]
unsafe extern "C" {
    static NSFileProtectionNone: &'static ns::FileProtectionType;
    static NSFileProtectionComplete: &'static ns::FileProtectionType;
    static NSFileProtectionCompleteUnlessOpen: &'static ns::FileProtectionType;
    static NSFileProtectionCompleteUntilFirstUserAuthentication: &'static ns::FileProtectionType;

    static NSFileSystemSize: &'static ns::FileAttrKey;
    static NSFileSystemFreeSize: &'static ns::FileAttrKey;
    static NSFileSystemNodes: &'static ns::FileAttrKey;
    static NSFileSystemFreeNodes: &'static ns::FileAttrKey;
    static NSFileType: &'static ns::FileAttrKey;
    static NSFileProtectionKey: &'static ns::FileAttrKey;

    static NSFileSize: &'static ns::FileAttrKey;
    static NSFileModificationDate: &'static ns::FileAttrKey;
    static NSFileReferenceCount: &'static ns::FileAttrKey;
    static NSFileDeviceIdentifier: &'static ns::FileAttrKey;
    static NSFileOwnerAccountName: &'static ns::FileAttrKey;
    static NSFileGroupOwnerAccountName: &'static ns::FileAttrKey;
    static NSFilePosixPermissions: &'static ns::FileAttrKey;
    static NSFileSystemNumber: &'static ns::FileAttrKey;
    static NSFileSystemFileNumber: &'static ns::FileAttrKey;
    static NSFileExtensionHidden: &'static ns::FileAttrKey;
    static NSFileHFSCreatorCode: &'static ns::FileAttrKey;
    static NSFileHFSTypeCode: &'static ns::FileAttrKey;
    static NSFileImmutable: &'static ns::FileAttrKey;
    static NSFileAppendOnly: &'static ns::FileAttrKey;
    static NSFileCreationDate: &'static ns::FileAttrKey;
    static NSFileOwnerAccountID: &'static ns::FileAttrKey;
    static NSFileGroupOwnerAccountID: &'static ns::FileAttrKey;
    static NSFileBusy: &'static ns::FileAttrKey;

    static NSFileTypeDirectory: &'static ns::FileAttrType;
    static NSFileTypeRegular: &'static ns::FileAttrType;
    static NSFileTypeSymbolicLink: &'static ns::FileAttrType;
    static NSFileTypeSocket: &'static ns::FileAttrType;
    static NSFileTypeCharacterSpecial: &'static ns::FileAttrType;
    static NSFileTypeBlockSpecial: &'static ns::FileAttrType;
    static NSFileTypeUnknown: &'static ns::FileAttrType;
}

impl FileAttrKey {
    #[inline]
    pub fn file_type() -> &'static Self {
        unsafe { NSFileType }
    }

    #[inline]
    pub fn file_protection() -> &'static Self {
        unsafe { NSFileProtectionKey }
    }

    #[inline]
    pub fn file_system_size() -> &'static Self {
        unsafe { NSFileSystemSize }
    }

    #[inline]
    pub fn file_system_free_size() -> &'static Self {
        unsafe { NSFileSystemFreeSize }
    }

    #[inline]
    pub fn file_system_nodes() -> &'static Self {
        unsafe { NSFileSystemNodes }
    }

    #[inline]
    pub fn file_system_free_nodes() -> &'static Self {
        unsafe { NSFileSystemFreeNodes }
    }

    #[inline]
    pub fn size() -> &'static Self {
        unsafe { NSFileSize }
    }

    #[inline]
    pub fn modification_date() -> &'static Self {
        unsafe { NSFileModificationDate }
    }
    #[inline]
    pub fn reference_count() -> &'static Self {
        unsafe { NSFileReferenceCount }
    }

    #[inline]
    pub fn device_id() -> &'static Self {
        unsafe { NSFileDeviceIdentifier }
    }

    #[inline]
    pub fn owner_account_name() -> &'static Self {
        unsafe { NSFileOwnerAccountName }
    }

    #[inline]
    pub fn group_owner_account_name() -> &'static Self {
        unsafe { NSFileGroupOwnerAccountName }
    }

    #[inline]
    pub fn posix_permissions() -> &'static Self {
        unsafe { NSFilePosixPermissions }
    }

    #[inline]
    pub fn file_system_number() -> &'static Self {
        unsafe { NSFileSystemNumber }
    }

    #[inline]
    pub fn file_system_file_number() -> &'static Self {
        unsafe { NSFileSystemFileNumber }
    }

    #[inline]
    pub fn extension_hidden() -> &'static Self {
        unsafe { NSFileExtensionHidden }
    }

    #[inline]
    pub fn hfs_creator_code() -> &'static Self {
        unsafe { NSFileHFSCreatorCode }
    }

    #[inline]
    pub fn hfs_type_code() -> &'static Self {
        unsafe { NSFileHFSTypeCode }
    }

    #[inline]
    pub fn immutable() -> &'static Self {
        unsafe { NSFileImmutable }
    }

    #[inline]
    pub fn append_only() -> &'static Self {
        unsafe { NSFileAppendOnly }
    }

    #[inline]
    pub fn creation_date() -> &'static Self {
        unsafe { NSFileCreationDate }
    }

    #[inline]
    pub fn owner_account_id() -> &'static Self {
        unsafe { NSFileOwnerAccountID }
    }

    #[inline]
    pub fn group_owner_account_id() -> &'static Self {
        unsafe { NSFileGroupOwnerAccountID }
    }
    #[inline]
    pub fn busy() -> &'static Self {
        unsafe { NSFileBusy }
    }
}

impl FileAttrType {
    #[inline]
    pub fn directory() -> &'static Self {
        unsafe { NSFileTypeDirectory }
    }

    #[inline]
    pub fn regular() -> &'static Self {
        unsafe { NSFileTypeRegular }
    }

    #[inline]
    pub fn symbolic_link() -> &'static Self {
        unsafe { NSFileTypeSymbolicLink }
    }

    #[inline]
    pub fn socket() -> &'static Self {
        unsafe { NSFileTypeSocket }
    }

    #[inline]
    pub fn character_special() -> &'static Self {
        unsafe { NSFileTypeCharacterSpecial }
    }

    #[inline]
    pub fn block_special() -> &'static Self {
        unsafe { NSFileTypeBlockSpecial }
    }

    #[inline]
    pub fn unknown() -> &'static Self {
        unsafe { NSFileTypeUnknown }
    }
}

impl FileProtectionType {
    #[inline]
    pub fn none() -> &'static Self {
        unsafe { NSFileProtectionNone }
    }

    #[inline]
    pub fn complete() -> &'static Self {
        unsafe { NSFileProtectionComplete }
    }
    #[inline]
    pub fn complete_unless_open() -> &'static Self {
        unsafe { NSFileProtectionCompleteUnlessOpen }
    }

    #[inline]
    pub fn complete_until_first_user_authentication() -> &'static Self {
        unsafe { NSFileProtectionCompleteUntilFirstUserAuthentication }
    }
}

impl<K: objc::Obj, V: objc::Obj> ns::Dictionary<K, V> {
    #[objc::msg_send(fileSize)]
    pub fn file_size(&self) -> usize;

    #[objc::msg_send(file_type)]
    pub fn file_type(&self) -> Option<arc::R<ns::String>>;

    #[objc::msg_send(file_type)]
    pub fn file_posix_permissions(&self) -> ns::UInteger;

    #[objc::msg_send(fileOwnerAccountName)]
    pub fn file_owner_account_name(&self) -> Option<arc::R<ns::String>>;

    #[objc::msg_send(fileGroupOwnerAccountName)]
    pub fn file_group_owner_account_name(&self) -> Option<arc::R<ns::String>>;

    #[objc::msg_send(fileSystemNumber)]
    pub fn file_system_number(&self) -> ns::Integer;

    #[objc::msg_send(fileSystemFileNumber)]
    pub fn file_system_file_number(&self) -> ns::UInteger;

    #[objc::msg_send(fileExtensionHidden)]
    pub fn file_extension_hidden(&self) -> bool;

    #[objc::msg_send(fileHFSCreatorCode)]
    pub fn file_hfs_creator_code(&self) -> os::Type;

    #[objc::msg_send(fileHFSTypeCode)]
    pub fn file_hfs_type_code(&self) -> os::Type;

    #[objc::msg_send(fileIsImmutable)]
    pub fn file_is_immutable(&self) -> bool;

    #[objc::msg_send(fileIsAppendOnly)]
    pub fn file_is_append_only(&self) -> bool;

    #[objc::msg_send(fileModificationDate)]
    pub fn file_modification_date(&self) -> Option<arc::R<ns::Date>>;

    #[objc::msg_send(fileCreationDate)]
    pub fn file_creation_date(&self) -> Option<arc::R<ns::Date>>;

    #[objc::msg_send(fileOwnerAccountID)]
    pub fn file_owner_account_id(&self) -> Option<arc::R<ns::Number>>;

    #[objc::msg_send(fileGroupOwnerAccountID)]
    pub fn file_group_owner_account_id(&self) -> Option<arc::R<ns::Number>>;
}

#[cfg(test)]
mod tests {
    use crate::ns;

    #[test]
    fn basics() {
        let fm = ns::FileManager::default();
        println!("{fm:?}");
        let url = ns::Url::with_fs_path_str("/tmp/", true);
        let list = fm
            .contents_of_dir_at_url(&url, None, Default::default())
            .expect("Failed to list {url:?}");
        assert!(!list.is_empty());
    }

    #[test]
    fn throws() {
        //> Passing a directory and domain pair that makes no sense
        //> (for example NSDesktopDirectory and NSNetworkDomainMask) raises an exception.
        //
        // but actually it doesn't raises an exception. It just return none as error and none as result

        // NOTE: on macos 15.1 Beta (24B5035e) it is not a case

        // let fm = ns::FileManager::default();

        // let pwd = fm.current_dir_path();
        // assert!(!pwd.is_empty());

        // let err = ns::try_catch(|| {
        //     let f = fm.url_for_dir(
        //         ns::SearchPathDirectory::Desktop,
        //         ns::SearchPathDomainMask::NETWORK,
        //         None,
        //         true,
        //     );
        //     println!("{f:?}");
        //     f.err().unwrap()
        // });

        // assert_eq!(Ok(None), err);
    }

    #[test]
    pub fn create_dir() {
        let parent = ns::str!(c"/tmp/foo");

        let path = ns::str!(c"/tmp/foo/nest");
        let fm = ns::FileManager::default();

        let _r = fm.remove_item_at_path(parent); // don't care about result for now

        fm.create_dir_at_path(path, false, None)
            .expect_err("should fail");

        fm.create_dir_at_path(path, true, None).unwrap();
        assert!(fm.file_exists_at_path(&path));

        fm.remove_item_at_path(parent).unwrap();
        assert!(!fm.file_exists_at_path(parent));
    }

    #[cfg(target_os = "macos")]
    #[test]
    pub fn list_mounts() {
        let keys = ns::Array::from_slice(&[
            ns::UrlResKey::name(),
            ns::UrlResKey::is_volume(),
            ns::UrlResKey::path(),
            ns::UrlResKey::volume_url(),
            ns::UrlResKey::volume_id(),
            ns::UrlResKey::volume_localized_format_desc(),
            ns::UrlResKey::volume_total_capacity(),
            ns::UrlResKey::volume_url_for_remounting(),
            ns::UrlResKey::volume_mount_from_location(),
            ns::UrlResKey::volume_type_name(),
            ns::UrlResKey::volume_sub_type_name(),
        ]);

        let fm = ns::FileManager::default();
        let list = fm.mounted_volume_urls(Some(&keys), Default::default());

        for url in list.iter() {
            let values = url.res_values_for_keys(&keys);
            eprintln!("{values:?}");
        }
        // list.first().unwrap().att
        eprintln!("{list:?}");
    }
}