@@ -10,6 +10,7 @@ mod stat {
1010 #[ cfg( not( any( unix, windows) ) ) ]
1111 type Mode = u32 ; // Fallback for unknown targets
1212
13+ // unix_libc_get
1314 cfg_if:: cfg_if! {
1415 if #[ cfg( unix) ] {
1516 macro_rules! unix_libc_get {
@@ -24,6 +25,24 @@ mod stat {
2425 } ;
2526 }
2627 }
28+
29+ }
30+
31+ // macos_libc_get
32+ cfg_if:: cfg_if! {
33+ if #[ cfg( target_os = "macos" ) ] {
34+ macro_rules! macos_libc_get {
35+ ( $name: ident, $val: expr) => {
36+ libc:: $name
37+ } ;
38+ }
39+ } else {
40+ macro_rules! macos_libc_get {
41+ ( $name: ident, $val: expr) => {
42+ $val
43+ } ;
44+ }
45+ }
2746 }
2847
2948 #[ pyattr]
@@ -316,6 +335,7 @@ mod stat {
316335 }
317336
318337 // Windows file attributes (if on Windows)
338+
319339 #[ cfg( windows) ]
320340 #[ pyattr]
321341 pub use windows_sys:: Win32 :: Storage :: FileSystem :: {
@@ -328,71 +348,43 @@ mod stat {
328348 } ;
329349
330350 // Unix file flags (if on Unix)
331- #[ cfg( target_os = "macos" ) ]
332- #[ pyattr]
333- pub const UF_NODUMP : u32 = libc:: UF_NODUMP ;
334- #[ cfg( not( target_os = "macos" ) ) ]
335- #[ pyattr]
336- pub const UF_NODUMP : u32 = 0x00000001 ;
337351
338- #[ cfg( target_os = "macos" ) ]
339- #[ pyattr]
340- pub const UF_IMMUTABLE : u32 = libc:: UF_IMMUTABLE ;
341- #[ cfg( not( target_os = "macos" ) ) ]
342352 #[ pyattr]
343- pub const UF_IMMUTABLE : u32 = 0x00000002 ;
353+ pub const UF_NODUMP : u32 = macos_libc_get ! ( UF_NODUMP , 0x00000001 ) ;
344354
345- #[ cfg( target_os = "macos" ) ]
346- #[ pyattr]
347- pub const UF_APPEND : u32 = libc:: UF_APPEND ;
348- #[ cfg( not( target_os = "macos" ) ) ]
349355 #[ pyattr]
350- pub const UF_APPEND : u32 = 0x00000004 ;
356+ pub const UF_IMMUTABLE : u32 = macos_libc_get ! ( UF_IMMUTABLE , 0x00000002 ) ;
351357
352- #[ cfg( target_os = "macos" ) ]
353- #[ pyattr]
354- pub const UF_OPAQUE : u32 = libc:: UF_OPAQUE ;
355- #[ cfg( not( target_os = "macos" ) ) ]
356358 #[ pyattr]
357- pub const UF_OPAQUE : u32 = 0x00000008 ;
359+ pub const UF_APPEND : u32 = macos_libc_get ! ( UF_APPEND , 0x00000004 ) ;
358360
359361 #[ pyattr]
360- pub const UF_NOUNLINK : u32 = 0x00000010 ;
362+ pub const UF_OPAQUE : u32 = macos_libc_get ! ( UF_OPAQUE , 0x00000008 ) ;
361363
362- #[ cfg( target_os = "macos" ) ]
363- #[ pyattr]
364- pub const UF_COMPRESSED : u32 = libc:: UF_COMPRESSED ;
365- #[ cfg( not( target_os = "macos" ) ) ]
366364 #[ pyattr]
367- pub const UF_COMPRESSED : u32 = 0x00000020 ;
365+ pub const UF_COMPRESSED : u32 = macos_libc_get ! ( UF_COMPRESSED , 0x00000020 ) ;
368366
369- #[ cfg( target_os = "macos" ) ]
370367 #[ pyattr]
371- pub const UF_HIDDEN : u32 = libc:: UF_HIDDEN ;
372- #[ cfg( not( target_os = "macos" ) ) ]
373- #[ pyattr]
374- pub const UF_HIDDEN : u32 = 0x00008000 ;
368+ pub const UF_HIDDEN : u32 = macos_libc_get ! ( UF_HIDDEN , 0x00008000 ) ;
375369
376- #[ cfg( target_os = "macos" ) ]
377- #[ pyattr]
378- pub const SF_ARCHIVED : u32 = libc:: SF_ARCHIVED ;
379- #[ cfg( not( target_os = "macos" ) ) ]
380370 #[ pyattr]
381- pub const SF_ARCHIVED : u32 = 0x00010000 ;
371+ pub const SF_ARCHIVED : u32 = macos_libc_get ! ( SF_ARCHIVED , 0x00010000 ) ;
382372
383- #[ cfg( target_os = "macos" ) ]
384373 #[ pyattr]
385- pub const SF_IMMUTABLE : u32 = libc :: SF_IMMUTABLE ;
386- # [ cfg ( not ( target_os = "macos" ) ) ]
374+ pub const SF_IMMUTABLE : u32 = macos_libc_get ! ( SF_IMMUTABLE , 0x00020000 ) ;
375+
387376 #[ pyattr]
388- pub const SF_IMMUTABLE : u32 = 0x00020000 ;
377+ pub const SF_APPEND : u32 = macos_libc_get ! ( SF_APPEND , 0x00040000 ) ;
389378
390- #[ cfg( target_os = "macos" ) ]
391379 #[ pyattr]
392- pub const SF_APPEND : u32 = libc:: SF_APPEND ;
393- #[ cfg( not( target_os = "macos" ) ) ]
380+ pub const SF_SETTABLE : u32 = if cfg ! ( target_os = "macos" ) {
381+ 0x3fff0000
382+ } else {
383+ 0xffff0000
384+ } ;
385+
394386 #[ pyattr]
395- pub const SF_APPEND : u32 = 0x00040000 ;
387+ pub const UF_NOUNLINK : u32 = 0x00000010 ;
396388
397389 #[ pyattr]
398390 pub const SF_NOUNLINK : u32 = 0x00100000 ;
@@ -406,16 +398,11 @@ mod stat {
406398 #[ pyattr]
407399 pub const SF_DATALESS : u32 = 0x40000000 ;
408400
409- #[ cfg( target_os = "macos" ) ]
410- #[ pyattr]
411- pub const SF_SUPPORTED : u32 = 0x009f0000 ;
401+ // MacOS specific
412402
413403 #[ cfg( target_os = "macos" ) ]
414404 #[ pyattr]
415- pub const SF_SETTABLE : u32 = 0x3fff0000 ;
416- #[ cfg( not( target_os = "macos" ) ) ]
417- #[ pyattr]
418- pub const SF_SETTABLE : u32 = 0xffff0000 ;
405+ pub const SF_SUPPORTED : u32 = 0x009f0000 ;
419406
420407 #[ cfg( target_os = "macos" ) ]
421408 #[ pyattr]
0 commit comments