1 /** 2 * D header file for POSIX. 3 * 4 * Copyright: Copyright Sean Kelly 2005 - 2009. 5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0). 6 * Authors: Sean Kelly, Alex Rønne Petersen 7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition 8 */ 9 10 /* Copyright Sean Kelly 2005 - 2009. 11 * Distributed under the Boost Software License, Version 1.0. 12 * (See accompanying file LICENSE or copy at 13 * http://www.boost.org/LICENSE_1_0.txt) 14 */ 15 module core.sys.posix.sys.stat; 16 17 import core.sys.posix.config; 18 import core.stdc.stdint; 19 import core.sys.posix.time; // for timespec 20 public import core.sys.posix.sys.types; // for off_t, mode_t 21 22 version (OSX) 23 version = Darwin; 24 else version (iOS) 25 version = Darwin; 26 else version (TVOS) 27 version = Darwin; 28 else version (WatchOS) 29 version = Darwin; 30 31 version (RISCV32) version = RISCV_Any; 32 version (RISCV64) version = RISCV_Any; 33 version (SPARC) version = SPARC_Any; 34 version (SPARC64) version = SPARC_Any; 35 36 version (Posix): 37 extern (C) nothrow @nogc: 38 39 // 40 // Required 41 // 42 /* 43 struct stat 44 { 45 dev_t st_dev; 46 ino_t st_ino; 47 mode_t st_mode; 48 nlink_t st_nlink; 49 uid_t st_uid; 50 gid_t st_gid; 51 off_t st_size; 52 time_t st_atime; 53 time_t st_mtime; 54 time_t st_ctime; 55 } 56 57 S_ISUID 58 S_ISGID 59 S_ISVTX 60 61 S_TYPEISMQ(buf) 62 S_TYPEISSEM(buf) 63 S_TYPEISSHM(buf) 64 */ 65 66 version (linux) 67 { 68 version (X86) 69 { 70 struct stat_t 71 { 72 dev_t st_dev; 73 ushort __pad1; 74 mode_t st_mode; 75 nlink_t st_nlink; 76 uid_t st_uid; 77 gid_t st_gid; 78 dev_t st_rdev; 79 ushort __pad2; 80 off_t st_size; 81 blksize_t st_blksize; 82 blkcnt_t st_blocks; 83 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) 84 { 85 timespec st_atim; 86 timespec st_mtim; 87 timespec st_ctim; 88 extern(D) @safe @property inout pure nothrow 89 { 90 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 91 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 92 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 93 } 94 } 95 else 96 { 97 time_t st_atime; 98 ulong_t st_atimensec; 99 time_t st_mtime; 100 ulong_t st_mtimensec; 101 time_t st_ctime; 102 ulong_t st_ctimensec; 103 } 104 version (CRuntime_Musl) 105 { 106 ino_t st_ino; 107 c_ulong __unused4; 108 c_ulong __unused5; 109 } 110 else 111 { 112 static if (__USE_FILE_OFFSET64) 113 { 114 uint __st_ino; 115 ino_t st_ino; 116 } 117 else 118 { 119 ino_t st_ino; 120 c_ulong __unused4; 121 c_ulong __unused5; 122 } 123 } 124 } 125 } 126 else version (X86_64) 127 { 128 struct stat_t 129 { 130 dev_t st_dev; 131 ino_t st_ino; 132 nlink_t st_nlink; 133 mode_t st_mode; 134 uid_t st_uid; 135 gid_t st_gid; 136 uint __pad0; 137 dev_t st_rdev; 138 off_t st_size; 139 blksize_t st_blksize; 140 blkcnt_t st_blocks; 141 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) 142 { 143 timespec st_atim; 144 timespec st_mtim; 145 timespec st_ctim; 146 extern(D) @safe @property inout pure nothrow 147 { 148 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 149 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 150 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 151 } 152 } 153 else 154 { 155 time_t st_atime; 156 ulong_t st_atimensec; 157 time_t st_mtime; 158 ulong_t st_mtimensec; 159 time_t st_ctime; 160 ulong_t st_ctimensec; 161 } 162 slong_t[3] __unused; 163 } 164 } 165 else version (HPPA) 166 { 167 private 168 { 169 alias __dev_t = ulong; 170 alias __ino_t = c_ulong; 171 alias __ino64_t = ulong; 172 alias __mode_t = uint; 173 alias __nlink_t = size_t; 174 alias __uid_t = uint; 175 alias __gid_t = uint; 176 alias __off_t = c_long; 177 alias __off64_t = long; 178 alias __blksize_t = c_long; 179 alias __blkcnt_t = c_long; 180 alias __blkcnt64_t = long; 181 alias __timespec = timespec; 182 alias __time_t = time_t; 183 } 184 struct stat_t 185 { 186 __dev_t st_dev; 187 ushort __pad1; 188 189 __mode_t st_mode; 190 __nlink_t st_nlink; 191 __uid_t st_uid; 192 __gid_t st_gid; 193 __dev_t st_rdev; 194 ushort __pad2; 195 196 version (CRuntime_Musl) 197 { 198 __ino_t st_ino; 199 __off_t st_size; 200 __blkcnt_t st_blocks; 201 c_ulong __unused4; 202 c_ulong __unused5; 203 } 204 else 205 { 206 static if (!__USE_FILE_OFFSET64) 207 { 208 __ino_t st_ino; 209 __off_t st_size; 210 __blkcnt_t st_blocks; 211 c_ulong __unused4; 212 c_ulong __unused5; 213 } 214 else 215 { 216 __ino_t __st_ino; 217 __off64_t st_size; 218 __blkcnt64_t st_blocks; 219 __ino64_t st_ino; 220 } 221 } 222 __blksize_t st_blksize; 223 224 static if ( _DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) 225 { 226 __timespec st_atim; 227 __timespec st_mtim; 228 __timespec st_ctim; 229 extern(D) @safe @property inout pure nothrow 230 { 231 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 232 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 233 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 234 } 235 } 236 else 237 { 238 __time_t st_atime; 239 c_ulong st_atimensec; 240 __time_t st_mtime; 241 c_ulong st_mtimensec; 242 __time_t st_ctime; 243 c_ulong st_ctimensec; 244 } 245 } 246 version (CRuntime_Musl) 247 { 248 static assert(stat_t.sizeof == 88); 249 } 250 else 251 { 252 static if (__USE_FILE_OFFSET64) 253 static assert(stat_t.sizeof == 104); 254 else 255 static assert(stat_t.sizeof == 88); 256 } 257 } 258 else version (MIPS_O32) 259 { 260 struct stat_t 261 { 262 c_ulong st_dev; 263 c_long[3] st_pad1; 264 ino_t st_ino; 265 mode_t st_mode; 266 nlink_t st_nlink; 267 uid_t st_uid; 268 gid_t st_gid; 269 c_ulong st_rdev; 270 version (CRuntime_Musl) 271 { 272 c_long[2] st_pad2; 273 off_t st_size; 274 c_long st_pad3; 275 blkcnt_t st_blocks; 276 } 277 else 278 { 279 static if (!__USE_FILE_OFFSET64) 280 { 281 c_long[2] st_pad2; 282 off_t st_size; 283 c_long st_pad3; 284 blkcnt_t st_blocks; 285 } 286 else 287 { 288 c_long[3] st_pad2; 289 off_t st_size; 290 c_long st_pad4; 291 blkcnt_t st_blocks; 292 } 293 } 294 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) 295 { 296 timespec st_atim; 297 timespec st_mtim; 298 timespec st_ctim; 299 extern(D) @safe @property inout pure nothrow 300 { 301 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 302 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 303 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 304 } 305 } 306 else 307 { 308 time_t st_atime; 309 c_ulong st_atimensec; 310 time_t st_mtime; 311 c_ulong st_mtimensec; 312 time_t st_ctime; 313 c_ulong st_ctimensec; 314 } 315 blksize_t st_blksize; 316 c_long[14] st_pad5; 317 } 318 version (CRuntime_Musl) 319 { 320 static assert(stat_t.sizeof == 144); 321 } 322 else 323 { 324 static if (!__USE_FILE_OFFSET64) 325 static assert(stat_t.sizeof == 144); 326 else 327 static assert(stat_t.sizeof == 160); 328 } 329 } 330 else version (MIPS64) 331 { 332 struct stat_t 333 { 334 dev_t st_dev; 335 int[3] st_pad1; 336 ino_t st_ino; 337 mode_t st_mode; 338 nlink_t st_nlink; 339 uid_t st_uid; 340 gid_t st_gid; 341 dev_t st_rdev; 342 version (CRuntime_Musl) 343 { 344 uint[2] st_pad2; 345 off_t st_size; 346 int st_pad3; 347 } 348 else 349 { 350 static if (!__USE_FILE_OFFSET64) 351 { 352 uint[2] st_pad2; 353 off_t st_size; 354 int st_pad3; 355 } 356 else 357 { 358 uint[3] st_pad2; 359 off_t st_size; 360 } 361 } 362 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) 363 { 364 timespec st_atim; 365 timespec st_mtim; 366 timespec st_ctim; 367 extern(D) @safe @property inout pure nothrow 368 { 369 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 370 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 371 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 372 } 373 } 374 else 375 { 376 time_t st_atime; 377 c_ulong st_atimensec; 378 time_t st_mtime; 379 c_ulong st_mtimensec; 380 time_t st_ctime; 381 c_ulong st_ctimensec; 382 } 383 blksize_t st_blksize; 384 uint st_pad4; 385 blkcnt_t st_blocks; 386 int[14] st_pad5; 387 } 388 version (MIPS_N32) 389 { 390 version (CRuntime_Musl) 391 { 392 static assert(stat_t.sizeof == 160); 393 } 394 else 395 { 396 static if (!__USE_FILE_OFFSET64) 397 static assert(stat_t.sizeof == 160); 398 else 399 static assert(stat_t.sizeof == 176); 400 } 401 } 402 else version (MIPS_O64) 403 { 404 version (CRuntime_Musl) 405 { 406 static assert(stat_t.sizeof == 160); 407 } 408 else 409 { 410 static if (!__USE_FILE_OFFSET64) 411 static assert(stat_t.sizeof == 160); 412 else 413 static assert(stat_t.sizeof == 176); 414 } 415 } 416 else 417 { 418 static assert(stat_t.sizeof == 216); 419 } 420 } 421 else version (PPC) 422 { 423 struct stat_t 424 { 425 dev_t st_dev; 426 version (CRuntime_Musl) 427 { 428 ino_t st_ino; 429 } 430 else 431 { 432 static if (!__USE_FILE_OFFSET64) 433 { 434 ushort __pad1; 435 ino_t st_ino; 436 } 437 else 438 ino_t st_ino; 439 } 440 mode_t st_mode; 441 nlink_t st_nlink; 442 uid_t st_uid; 443 gid_t st_gid; 444 dev_t st_rdev; 445 ushort __pad2; 446 off_t st_size; 447 blksize_t st_blksize; 448 blkcnt_t st_blocks; 449 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) 450 { 451 timespec st_atim; 452 timespec st_mtim; 453 timespec st_ctim; 454 extern(D) @safe @property inout pure nothrow 455 { 456 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 457 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 458 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 459 } 460 } 461 else 462 { 463 time_t st_atime; 464 c_ulong st_atimensec; 465 time_t st_mtime; 466 c_ulong st_mtimensec; 467 time_t st_ctime; 468 c_ulong st_ctimensec; 469 } 470 c_ulong __unused4; 471 c_ulong __unused5; 472 } 473 version (CRuntime_Musl) 474 { 475 static assert(stat_t.sizeof == 88); 476 } 477 else 478 { 479 static if (__USE_FILE_OFFSET64) 480 static assert(stat_t.sizeof == 104); 481 else 482 static assert(stat_t.sizeof == 88); 483 } 484 } 485 else version (PPC64) 486 { 487 struct stat_t 488 { 489 dev_t st_dev; 490 ino_t st_ino; 491 nlink_t st_nlink; 492 mode_t st_mode; 493 uid_t st_uid; 494 gid_t st_gid; 495 int __pad2; 496 dev_t st_rdev; 497 off_t st_size; 498 blksize_t st_blksize; 499 blkcnt_t st_blocks; 500 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) 501 { 502 timespec st_atim; 503 timespec st_mtim; 504 timespec st_ctim; 505 extern(D) @safe @property inout pure nothrow 506 { 507 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 508 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 509 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 510 } 511 } 512 else 513 { 514 time_t st_atime; 515 c_ulong st_atimensec; 516 time_t st_mtime; 517 c_ulong st_mtimensec; 518 time_t st_ctime; 519 c_ulong st_ctimensec; 520 } 521 c_ulong __unused4; 522 c_ulong __unused5; 523 c_ulong __unused6; 524 } 525 static assert(stat_t.sizeof == 144); 526 } 527 else version (RISCV_Any) 528 { 529 private 530 { 531 alias __dev_t = ulong; 532 alias __ino_t = c_ulong; 533 alias __ino64_t = ulong; 534 alias __mode_t = uint; 535 alias __nlink_t = uint; 536 alias __uid_t = uint; 537 alias __gid_t = uint; 538 alias __off_t = c_long; 539 alias __off64_t = long; 540 alias __blksize_t = int; 541 alias __blkcnt_t = c_long; 542 alias __blkcnt64_t = long; 543 alias __timespec = timespec; 544 alias __time_t = time_t; 545 } 546 struct stat_t 547 { 548 __dev_t st_dev; 549 550 version (CRuntime_Musl) 551 { 552 __ino_t st_ino; 553 __off_t st_size; 554 __blkcnt_t st_blocks; 555 } 556 else 557 { 558 static if (__USE_FILE_OFFSET64) 559 { 560 __ino64_t st_ino; 561 __off64_t st_size; 562 __blkcnt64_t st_blocks; 563 } 564 else 565 { 566 __ino_t st_ino; 567 __off_t st_size; 568 __blkcnt_t st_blocks; 569 } 570 } 571 __mode_t st_mode; 572 __nlink_t st_nlink; 573 __uid_t st_uid; 574 __gid_t st_gid; 575 __dev_t st_rdev; 576 __dev_t __pad1; 577 578 __blksize_t st_blksize; 579 int __pad2; 580 581 static if (_DEFAULT_SOURCE) 582 { 583 __timespec st_atim; 584 __timespec st_mtim; 585 __timespec st_ctim; 586 extern(D) @safe @property inout pure nothrow 587 { 588 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 589 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 590 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 591 } 592 } 593 else 594 { 595 __time_t st_atime; 596 c_ulong st_atimensec; 597 __time_t st_mtime; 598 c_ulong st_mtimensec; 599 __time_t st_ctime; 600 c_ulong st_ctimensec; 601 } 602 int[2] __unused; 603 } 604 } 605 else version (ARM) 606 { 607 private 608 { 609 alias __dev_t = ulong; 610 alias __ino_t = c_ulong; 611 alias __ino64_t = ulong; 612 alias __mode_t = uint; 613 alias __nlink_t = size_t; 614 alias __uid_t = uint; 615 alias __gid_t = uint; 616 alias __off_t = c_long; 617 alias __off64_t = long; 618 alias __blksize_t = c_long; 619 alias __blkcnt_t = c_long; 620 alias __blkcnt64_t = long; 621 alias __timespec = timespec; 622 alias __time_t = time_t; 623 } 624 struct stat_t 625 { 626 __dev_t st_dev; 627 ushort __pad1; 628 629 version (CRuntime_Musl) 630 { 631 __ino_t st_ino; 632 __off_t st_size; 633 __blkcnt_t st_blocks; 634 c_ulong __unused4; 635 c_ulong __unused5; 636 } 637 else 638 { 639 static if (!__USE_FILE_OFFSET64) 640 { 641 __ino_t st_ino; 642 __off_t st_size; 643 __blkcnt_t st_blocks; 644 c_ulong __unused4; 645 c_ulong __unused5; 646 } 647 else 648 { 649 __ino_t __st_ino; 650 __off64_t st_size; 651 __blkcnt64_t st_blocks; 652 __ino64_t st_ino; 653 } 654 } 655 __mode_t st_mode; 656 __nlink_t st_nlink; 657 __uid_t st_uid; 658 __gid_t st_gid; 659 __dev_t st_rdev; 660 ushort __pad2; 661 662 __blksize_t st_blksize; 663 664 static if ( _DEFAULT_SOURCE || _XOPEN_SOURCE >= 700) 665 { 666 __timespec st_atim; 667 __timespec st_mtim; 668 __timespec st_ctim; 669 extern(D) @safe @property inout pure nothrow 670 { 671 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 672 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 673 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 674 } 675 } 676 else 677 { 678 __time_t st_atime; 679 c_ulong st_atimensec; 680 __time_t st_mtime; 681 c_ulong st_mtimensec; 682 __time_t st_ctime; 683 c_ulong st_ctimensec; 684 } 685 } 686 version (CRuntime_Musl) 687 { 688 static assert(stat_t.sizeof == 88); 689 } 690 else 691 { 692 static if (__USE_FILE_OFFSET64) 693 static assert(stat_t.sizeof == 104); 694 else 695 static assert(stat_t.sizeof == 88); 696 } 697 } 698 else version (AArch64) 699 { 700 private 701 { 702 alias __dev_t = ulong; 703 alias __ino_t = c_ulong; 704 alias __ino64_t = ulong; 705 alias __mode_t = uint; 706 alias __nlink_t = uint; 707 alias __uid_t = uint; 708 alias __gid_t = uint; 709 alias __off_t = c_long; 710 alias __off64_t = long; 711 alias __blksize_t = int; 712 alias __blkcnt_t = c_long; 713 alias __blkcnt64_t = long; 714 alias __timespec = timespec; 715 alias __time_t = time_t; 716 } 717 struct stat_t 718 { 719 __dev_t st_dev; 720 721 version (CRuntime_Musl) 722 { 723 __ino_t st_ino; 724 __off_t st_size; 725 __blkcnt_t st_blocks; 726 } 727 else 728 { 729 static if (!__USE_FILE_OFFSET64) 730 { 731 __ino_t st_ino; 732 __off_t st_size; 733 __blkcnt_t st_blocks; 734 } 735 else 736 { 737 __ino64_t st_ino; 738 __off64_t st_size; 739 __blkcnt64_t st_blocks; 740 } 741 } 742 __mode_t st_mode; 743 __nlink_t st_nlink; 744 __uid_t st_uid; 745 __gid_t st_gid; 746 __dev_t st_rdev; 747 __dev_t __pad1; 748 749 __blksize_t st_blksize; 750 int __pad2; 751 752 static if (_DEFAULT_SOURCE) 753 { 754 __timespec st_atim; 755 __timespec st_mtim; 756 __timespec st_ctim; 757 extern(D) @safe @property inout pure nothrow 758 { 759 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 760 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 761 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 762 } 763 } 764 else 765 { 766 __time_t st_atime; 767 c_ulong st_atimensec; 768 __time_t st_mtime; 769 c_ulong st_mtimensec; 770 __time_t st_ctime; 771 c_ulong st_ctimensec; 772 } 773 int[2] __unused; 774 } 775 version (D_LP64) 776 static assert(stat_t.sizeof == 128); 777 else 778 static assert(stat_t.sizeof == 104); 779 } 780 else version (SPARC_Any) 781 { 782 private 783 { 784 alias __dev_t = ulong; 785 alias __ino_t = c_ulong; 786 alias __ino64_t = ulong; 787 alias __mode_t = uint; 788 alias __nlink_t = uint; 789 alias __uid_t = uint; 790 alias __gid_t = uint; 791 alias __off_t = c_long; 792 alias __off64_t = long; 793 alias __blksize_t = c_long; 794 alias __blkcnt_t = c_long; 795 alias __blkcnt64_t = long; 796 alias __timespec = timespec; 797 alias __time_t = time_t; 798 } 799 struct stat_t 800 { 801 __dev_t st_dev; 802 static if (__WORDSIZE == 64 || !__USE_FILE_OFFSET64) 803 { 804 ushort __pad1; 805 __ino_t st_ino; 806 } 807 else 808 { 809 __ino64_t st_ino; 810 } 811 __mode_t st_mode; 812 __nlink_t st_nlink; 813 __uid_t st_uid; 814 __gid_t st_gid; 815 __dev_t st_rdev; 816 ushort __pad2; 817 818 version (CRuntime_Musl) 819 { 820 __off_t st_size; 821 __blkcnt_t st_blocks; 822 } 823 else 824 { 825 static if (!__USE_FILE_OFFSET64) 826 { 827 __off_t st_size; 828 __blkcnt_t st_blocks; 829 } 830 else 831 { 832 __off64_t st_size; 833 __blkcnt64_t st_blocks; 834 } 835 } 836 __blksize_t st_blksize; 837 838 static if (_XOPEN_SOURCE >= 700) 839 { 840 __timespec st_atim; 841 __timespec st_mtim; 842 __timespec st_ctim; 843 extern(D) @safe @property inout pure nothrow 844 { 845 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 846 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 847 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 848 } 849 } 850 else 851 { 852 __time_t st_atime; 853 c_ulong st_atimensec; 854 __time_t st_mtime; 855 c_ulong st_mtimensec; 856 __time_t st_ctime; 857 c_ulong st_ctimensec; 858 } 859 860 c_ulong __unused4; 861 c_ulong __unused5; 862 } 863 version (CRuntime_Musl) 864 { 865 static if (__WORDSIZE == 64) 866 static assert(stat_t.sizeof == 144); 867 else 868 static assert(stat_t.sizeof == 88); 869 } 870 else 871 { 872 static if (__USE_LARGEFILE64) alias stat_t stat64_t; 873 874 static if (__WORDSIZE == 64) 875 static assert(stat_t.sizeof == 144); 876 else static if (__USE_FILE_OFFSET64) 877 static assert(stat_t.sizeof == 104); 878 else 879 static assert(stat_t.sizeof == 88); 880 } 881 882 } 883 else version (S390) 884 { 885 private 886 { 887 alias __dev_t = ulong; 888 alias __ino_t = c_ulong; 889 alias __ino64_t = ulong; 890 alias __mode_t = uint; 891 alias __nlink_t = uint; 892 alias __uid_t = uint; 893 alias __gid_t = uint; 894 alias __off_t = c_long; 895 alias __off64_t = long; 896 alias __blksize_t = c_long; 897 alias __blkcnt_t = c_long; 898 alias __blkcnt64_t = long; 899 alias __timespec = timespec; 900 alias __time_t = time_t; 901 } 902 struct stat_t 903 { 904 __dev_t st_dev; 905 uint __pad1; 906 static if (!__USE_FILE_OFFSET64) 907 __ino_t st_ino; 908 else 909 __ino_t __st_ino; 910 __mode_t st_mode; 911 __nlink_t st_nlink; 912 __uid_t st_uid; 913 __gid_t st_gid; 914 __dev_t st_rdev; 915 uint __pad2; 916 version (CRuntime_Musl) 917 { 918 __off_t st_size; 919 __blkcnt_t st_blocks; 920 } 921 else 922 { 923 static if (!__USE_FILE_OFFSET64) 924 { 925 __off_t st_size; 926 __blkcnt_t st_blocks; 927 } 928 else 929 { 930 __off64_t st_size; 931 __blkcnt64_t st_blocks; 932 } 933 } 934 __blksize_t st_blksize; 935 static if (_XOPEN_SOURCE >= 700) 936 { 937 __timespec st_atim; 938 __timespec st_mtim; 939 __timespec st_ctim; 940 extern(D) @safe @property inout pure nothrow 941 { 942 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 943 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 944 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 945 } 946 } 947 else 948 { 949 __time_t st_atime; 950 c_ulong st_atimensec; 951 __time_t st_mtime; 952 c_ulong st_mtimensec; 953 __time_t st_ctime; 954 c_ulong st_ctimensec; 955 } 956 static if (!__USE_FILE_OFFSET64) 957 { 958 c_ulong __glibc_reserved4; 959 c_ulong __glibc_reserved5; 960 } 961 else 962 __ino64_t st_ino; 963 } 964 version (CRuntime_Musl) 965 { 966 static assert(stat_t.sizeof == 88); 967 } 968 else 969 { 970 static if (__USE_FILE_OFFSET64) 971 static assert(stat_t.sizeof == 104); 972 else 973 static assert(stat_t.sizeof == 88); 974 } 975 } 976 else version (SystemZ) 977 { 978 private 979 { 980 alias __dev_t = ulong; 981 alias __ino_t = c_ulong; 982 alias __ino64_t = ulong; 983 alias __mode_t = uint; 984 alias __nlink_t = ulong; 985 alias __uid_t = uint; 986 alias __gid_t = uint; 987 alias __off_t = c_long; 988 alias __off64_t = long; 989 alias __blksize_t = c_long; 990 alias __blkcnt_t = c_long; 991 alias __blkcnt64_t = long; 992 alias __timespec = timespec; 993 alias __time_t = time_t; 994 } 995 struct stat_t 996 { 997 __dev_t st_dev; 998 __ino_t st_ino; 999 __nlink_t st_nlink; 1000 __mode_t st_mode; 1001 __uid_t st_uid; 1002 __gid_t st_gid; 1003 int __glibc_reserved0; 1004 __dev_t st_rdev; 1005 __off_t st_size; 1006 static if (_XOPEN_SOURCE >= 700) 1007 { 1008 __timespec st_atim; 1009 __timespec st_mtim; 1010 __timespec st_ctim; 1011 extern(D) @safe @property inout pure nothrow 1012 { 1013 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 1014 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 1015 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 1016 } 1017 } 1018 else 1019 { 1020 __time_t st_atime; 1021 c_ulong st_atimensec; 1022 __time_t st_mtime; 1023 c_ulong st_mtimensec; 1024 __time_t st_ctime; 1025 c_ulong st_ctimensec; 1026 } 1027 __blksize_t st_blksize; 1028 __blkcnt_t st_blocks; 1029 c_long[3] __glibc_reserved; 1030 } 1031 static if (_XOPEN_SOURCE >= 700) 1032 static assert(stat_t.sizeof == 144); 1033 else 1034 static assert(stat_t.sizeof == 144); 1035 } 1036 else version (LoongArch64) 1037 { 1038 private 1039 { 1040 alias __dev_t = ulong; 1041 alias __ino_t = c_ulong; 1042 alias __ino64_t = ulong; 1043 alias __mode_t = uint; 1044 alias __nlink_t = uint; 1045 alias __uid_t = uint; 1046 alias __gid_t = uint; 1047 alias __off_t = c_long; 1048 alias __off64_t = long; 1049 alias __blksize_t = int; 1050 alias __blkcnt_t = c_long; 1051 alias __blkcnt64_t = long; 1052 alias __timespec = timespec; 1053 alias __time_t = time_t; 1054 } 1055 struct stat_t 1056 { 1057 __dev_t st_dev; 1058 __ino_t st_ino; 1059 __mode_t st_mode; 1060 __nlink_t st_nlink; 1061 __uid_t st_uid; 1062 __gid_t st_gid; 1063 __dev_t st_rdev; 1064 __dev_t __pad1; 1065 // la64 always uses 64-bit file offsets 1066 __off64_t st_size; 1067 __blksize_t st_blksize; 1068 int __pad2; 1069 // la64 always uses 64-bit block counts 1070 __blkcnt64_t st_blocks; 1071 static if (_XOPEN_SOURCE >= 700) 1072 { 1073 __timespec st_atim; 1074 __timespec st_mtim; 1075 __timespec st_ctim; 1076 extern(D) @safe @property inout pure nothrow 1077 { 1078 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 1079 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 1080 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 1081 } 1082 } 1083 else 1084 { 1085 __time_t st_atime; 1086 c_ulong st_atimensec; 1087 __time_t st_mtime; 1088 c_ulong st_mtimensec; 1089 __time_t st_ctime; 1090 c_ulong st_ctimensec; 1091 } 1092 int[2] __glibc_reserved; 1093 } 1094 static assert(stat_t.sizeof == 128); 1095 } 1096 else 1097 static assert(0, "unimplemented"); 1098 1099 enum S_ISUID = 0x800; // octal 04000 1100 enum S_ISGID = 0x400; // octal 02000 1101 enum S_ISVTX = 0x200; // octal 01000 1102 1103 static if ( true /*__USE_POSIX199309*/ ) 1104 { 1105 extern bool S_TYPEISMQ( stat_t* buf ) { return false; } 1106 extern bool S_TYPEISSEM( stat_t* buf ) { return false; } 1107 extern bool S_TYPEISSHM( stat_t* buf ) { return false; } 1108 } 1109 1110 enum UTIME_NOW = 0x3fffffff; 1111 enum UTIME_OMIT = 0x3ffffffe; 1112 } 1113 else version (Darwin) 1114 { 1115 // _DARWIN_FEATURE_64_BIT_INODE stat is default for Mac OSX >10.5 and is 1116 // only meaningful type for other OS X/Darwin variants (e.g. iOS). 1117 // man stat(2) gives details. 1118 struct stat_t 1119 { 1120 dev_t st_dev; 1121 mode_t st_mode; 1122 nlink_t st_nlink; 1123 ino_t st_ino; 1124 uid_t st_uid; 1125 gid_t st_gid; 1126 dev_t st_rdev; 1127 union 1128 { 1129 struct 1130 { 1131 timespec st_atimespec; 1132 timespec st_mtimespec; 1133 timespec st_ctimespec; 1134 timespec st_birthtimespec; 1135 } 1136 struct 1137 { 1138 time_t st_atime; 1139 c_long st_atimensec; 1140 time_t st_mtime; 1141 c_long st_mtimensec; 1142 time_t st_ctime; 1143 c_long st_ctimensec; 1144 time_t st_birthtime; 1145 c_long st_birthtimensec; 1146 } 1147 } 1148 off_t st_size; 1149 blkcnt_t st_blocks; 1150 blksize_t st_blksize; 1151 uint st_flags; 1152 uint st_gen; 1153 int st_lspare; 1154 long[2] st_qspare; 1155 } 1156 1157 enum S_ISUID = 0x800; // octal 04000 1158 enum S_ISGID = 0x400; // octal 02000 1159 enum S_ISVTX = 0x200; // octal 01000 1160 } 1161 else version (FreeBSD) 1162 { 1163 import core.sys.freebsd.config; 1164 1165 // https://github.com/freebsd/freebsd/blob/master/sys/sys/stat.h 1166 static if (__FreeBSD_version >= INO64_FIRST) 1167 { 1168 struct stat_t 1169 { 1170 dev_t st_dev; 1171 ino_t st_ino; 1172 nlink_t st_nlink; 1173 mode_t st_mode; 1174 short st_padding0; 1175 uid_t st_uid; 1176 gid_t st_gid; 1177 int st_padding1; 1178 dev_t st_rdev; 1179 1180 version (X86) int st_atim_ext; 1181 timespec st_atim; 1182 1183 version (X86) int st_mtim_ext; 1184 timespec st_mtim; 1185 1186 version (X86) int st_ctim_ext; 1187 timespec st_ctim; 1188 1189 version (X86) int st_btim_ext; 1190 timespec st_birthtim; 1191 1192 off_t st_size; 1193 blkcnt_t st_blocks; 1194 blksize_t st_blksize; 1195 fflags_t st_flags; 1196 ulong st_gen; 1197 ulong[10] st_spare; 1198 1199 extern(D) @safe @property inout pure nothrow 1200 { 1201 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 1202 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 1203 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 1204 ref inout(time_t) st_birthtime() return { return st_birthtim.tv_sec; } 1205 } 1206 } 1207 } 1208 else 1209 { 1210 struct stat_t 1211 { 1212 uint st_dev; 1213 uint st_ino; 1214 mode_t st_mode; 1215 ushort st_nlink; 1216 uid_t st_uid; 1217 gid_t st_gid; 1218 uint st_rdev; 1219 timespec st_atim; 1220 timespec st_mtim; 1221 timespec st_ctim; 1222 off_t st_size; 1223 blkcnt_t st_blocks; 1224 blksize_t st_blksize; 1225 fflags_t st_flags; 1226 uint st_gen; 1227 int st_lspare; 1228 timespec st_birthtim; 1229 ubyte[16 - timespec.sizeof] padding; 1230 1231 extern(D) @safe @property inout pure nothrow 1232 { 1233 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 1234 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 1235 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 1236 ref inout(time_t) st_birthtime() return { return st_birthtim.tv_sec; } 1237 } 1238 } 1239 } 1240 1241 enum S_ISUID = 0x800; // octal 0004000 1242 enum S_ISGID = 0x400; // octal 0002000 1243 enum S_ISVTX = 0x200; // octal 0001000 1244 1245 enum UTIME_NOW = -1; 1246 enum UTIME_OMIT = -2; 1247 } 1248 else version (NetBSD) 1249 { 1250 struct stat_t 1251 { 1252 dev_t st_dev; /* inode's device */ 1253 mode_t st_mode; /* inode protection mode */ 1254 ino_t st_ino; /* inode's number */ 1255 nlink_t st_nlink; /* number of hard links */ 1256 uid_t st_uid; /* user ID of the file's owner */ 1257 gid_t st_gid; /* group ID of the file's group */ 1258 dev_t st_rdev; /* device type */ 1259 time_t st_atime; /* time of last access */ 1260 long st_atimensec; /* nsec of last access */ 1261 time_t st_mtime; /* time of last data modification */ 1262 long st_mtimensec; /* nsec of last data modification */ 1263 time_t st_ctime; /* time of last file status change */ 1264 long st_ctimensec; /* nsec of last file status change */ 1265 time_t st_birthtime; /* time of creation */ 1266 long st_birthtimensec; /* nsec of time of creation */ 1267 off_t st_size; /* file size, in bytes */ 1268 blkcnt_t st_blocks; /* blocks allocated for file */ 1269 blksize_t st_blksize; /* optimal blocksize for I/O */ 1270 uint32_t st_flags; /* user defined flags for file */ 1271 uint32_t st_gen; /* file generation number */ 1272 uint32_t[2] st_spare; 1273 } 1274 1275 enum S_ISUID = 0x800; // octal 0004000 1276 enum S_ISGID = 0x400; // octal 0002000 1277 enum S_ISVTX = 0x200; // octal 0001000 1278 } 1279 else version (OpenBSD) 1280 { 1281 import core.sys.openbsd.sys.cdefs; 1282 1283 struct stat_t 1284 { 1285 mode_t st_mode; 1286 dev_t st_dev; 1287 ino_t st_ino; 1288 nlink_t st_nlink; 1289 uid_t st_uid; 1290 gid_t st_gid; 1291 dev_t st_rdev; 1292 static if (__POSIX_VISIBLE >= 200809 || __BSD_VISIBLE) 1293 { 1294 timespec st_atim; 1295 timespec st_mtim; 1296 timespec st_ctim; 1297 extern(D) @safe @property inout pure nothrow 1298 { 1299 ref inout(time_t) st_atime() return { return st_atim.tv_sec; } 1300 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; } 1301 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; } 1302 } 1303 } 1304 else 1305 { 1306 time_t st_atime; 1307 long st_atimensec; 1308 time_t st_mtime; 1309 long st_mtimensec; 1310 time_t st_ctime; 1311 long st_ctimensec; 1312 } 1313 off_t st_size; 1314 blkcnt_t st_blocks; 1315 blksize_t st_blksize; 1316 uint32_t st_flags; 1317 uint32_t st_gen; 1318 static if (__POSIX_VISIBLE >= 200809 || __BSD_VISIBLE) 1319 { 1320 timespec __st_birthtim; 1321 } 1322 else 1323 { 1324 time_t __st_birthtime; 1325 long __st_birthtimensec; 1326 } 1327 } 1328 1329 enum S_ISUID = 0x800; // octal 0004000 1330 enum S_ISGID = 0x400; // octal 0002000 1331 enum S_ISVTX = 0x200; // octal 0001000 1332 } 1333 else version (DragonFlyBSD) 1334 { 1335 struct stat_t { 1336 ino_t st_ino; /* inode's number */ 1337 nlink_t st_nlink; /* number of hard links */ 1338 dev_t st_dev; /* inode's device */ 1339 mode_t st_mode; /* inode protection mode */ 1340 uint16_t st_padding1; 1341 uid_t st_uid; /* user ID of the file's owner */ 1342 gid_t st_gid; /* group ID of the file's group */ 1343 dev_t st_rdev; /* device type */ 1344 time_t st_atime; 1345 c_long __st_atimensec; 1346 time_t st_mtime; 1347 c_long __st_mtimensec; 1348 time_t st_ctime; 1349 c_long __st_ctimensec; 1350 off_t st_size; /* file size, in bytes */ 1351 int64_t st_blocks; /* blocks allocated for file */ 1352 uint32_t st_blksize; /* optimal blocksize for I/O */ 1353 uint32_t st_flags; /* user defined flags for file */ 1354 uint32_t st_gen; /* file generation number */ 1355 int32_t st_lspare; 1356 int64_t st_qspare1; /* was recursive change detect */ 1357 int64_t st_qspare2; 1358 } 1359 1360 enum S_ISUID = 0x800; // octal 0004000 1361 enum S_ISGID = 0x400; // octal 0002000 1362 enum S_ISVTX = 0x200; // octal 0001000 1363 } 1364 else version (Solaris) 1365 { 1366 private enum _ST_FSTYPSZ = 16; 1367 1368 version (D_LP64) 1369 { 1370 struct stat_t 1371 { 1372 dev_t st_dev; 1373 ino_t st_ino; 1374 mode_t st_mode; 1375 nlink_t st_nlink; 1376 uid_t st_uid; 1377 gid_t st_gid; 1378 dev_t st_rdev; 1379 off_t st_size; 1380 union 1381 { 1382 timestruc_t st_atim; 1383 time_t st_atime; 1384 } 1385 union 1386 { 1387 timestruc_t st_mtim; 1388 time_t st_mtime; 1389 } 1390 union 1391 { 1392 timestruc_t st_ctim; 1393 time_t st_ctime; 1394 } 1395 blksize_t st_blksize; 1396 blkcnt_t st_blocks; 1397 char[_ST_FSTYPSZ] st_fstype = 0; 1398 } 1399 1400 static if (__USE_LARGEFILE64) alias stat_t stat64_t; 1401 } 1402 else 1403 { 1404 struct stat32_t 1405 { 1406 dev_t st_dev; 1407 c_long[3] st_pad1; 1408 ino_t st_ino; 1409 mode_t st_mode; 1410 nlink_t st_nlink; 1411 uid_t st_uid; 1412 gid_t st_gid; 1413 dev_t st_rdev; 1414 c_long[2] st_pad2; 1415 off_t st_size; 1416 c_long st_pad3; 1417 union 1418 { 1419 timestruc_t st_atim; 1420 time_t st_atime; 1421 } 1422 union 1423 { 1424 timestruc_t st_mtim; 1425 time_t st_mtime; 1426 } 1427 union 1428 { 1429 timestruc_t st_ctim; 1430 time_t st_ctime; 1431 } 1432 blksize_t st_blksize; 1433 blkcnt_t st_blocks; 1434 char[_ST_FSTYPSZ] st_fstype = 0; 1435 c_long[8] st_pad4; 1436 } 1437 1438 struct stat64_t 1439 { 1440 dev_t st_dev; 1441 c_long[3] st_pad1; 1442 ino64_t st_ino; 1443 mode_t st_mode; 1444 nlink_t st_nlink; 1445 uid_t st_uid; 1446 gid_t st_gid; 1447 dev_t st_rdev; 1448 c_long[2] st_pad2; 1449 off64_t st_size; 1450 union 1451 { 1452 timestruc_t st_atim; 1453 time_t st_atime; 1454 } 1455 union 1456 { 1457 timestruc_t st_mtim; 1458 time_t st_mtime; 1459 } 1460 union 1461 { 1462 timestruc_t st_ctim; 1463 time_t st_ctime; 1464 } 1465 blksize_t st_blksize; 1466 blkcnt64_t st_blocks; 1467 char[_ST_FSTYPSZ] st_fstype = 0; 1468 c_long[8] st_pad4; 1469 } 1470 1471 static if (__USE_FILE_OFFSET64) 1472 alias stat64_t stat_t; 1473 else 1474 alias stat32_t stat_t; 1475 1476 } 1477 1478 enum S_ISUID = 0x800; 1479 enum S_ISGID = 0x400; 1480 enum S_ISVTX = 0x200; 1481 } 1482 else 1483 { 1484 static assert(false, "Unsupported platform"); 1485 } 1486 1487 /* 1488 S_IRWXU 1489 S_IRUSR 1490 S_IWUSR 1491 S_IXUSR 1492 S_IRWXG 1493 S_IRGRP 1494 S_IWGRP 1495 S_IXGRP 1496 S_IRWXO 1497 S_IROTH 1498 S_IWOTH 1499 S_IXOTH 1500 1501 S_ISBLK(m) 1502 S_ISCHR(m) 1503 S_ISDIR(m) 1504 S_ISFIFO(m) 1505 S_ISREG(m) 1506 S_ISLNK(m) 1507 S_ISSOCK(m) 1508 */ 1509 1510 version (CRuntime_Glibc) 1511 { 1512 enum S_IRUSR = 0x100; // octal 0400 1513 enum S_IWUSR = 0x080; // octal 0200 1514 enum S_IXUSR = 0x040; // octal 0100 1515 enum S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR; 1516 1517 enum S_IRGRP = S_IRUSR >> 3; 1518 enum S_IWGRP = S_IWUSR >> 3; 1519 enum S_IXGRP = S_IXUSR >> 3; 1520 enum S_IRWXG = S_IRWXU >> 3; 1521 1522 enum S_IROTH = S_IRGRP >> 3; 1523 enum S_IWOTH = S_IWGRP >> 3; 1524 enum S_IXOTH = S_IXGRP >> 3; 1525 enum S_IRWXO = S_IRWXG >> 3; 1526 1527 private 1528 { 1529 extern (D) bool S_ISTYPE( mode_t mode, uint mask ) 1530 { 1531 return ( mode & S_IFMT ) == mask; 1532 } 1533 } 1534 1535 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); } 1536 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); } 1537 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); } 1538 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); } 1539 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); } 1540 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } 1541 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } 1542 1543 int utimensat(int dirfd, const char *pathname, 1544 ref const(timespec)[2] times, int flags); 1545 int futimens(int fd, ref const(timespec)[2] times); 1546 } 1547 else version (Darwin) 1548 { 1549 enum S_IRUSR = 0x100; // octal 0400 1550 enum S_IWUSR = 0x080; // octal 0200 1551 enum S_IXUSR = 0x040; // octal 0100 1552 enum S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR; 1553 1554 enum S_IRGRP = S_IRUSR >> 3; 1555 enum S_IWGRP = S_IWUSR >> 3; 1556 enum S_IXGRP = S_IXUSR >> 3; 1557 enum S_IRWXG = S_IRWXU >> 3; 1558 1559 enum S_IROTH = S_IRGRP >> 3; 1560 enum S_IWOTH = S_IWGRP >> 3; 1561 enum S_IXOTH = S_IXGRP >> 3; 1562 enum S_IRWXO = S_IRWXG >> 3; 1563 1564 private 1565 { 1566 extern (D) bool S_ISTYPE( mode_t mode, uint mask ) 1567 { 1568 return ( mode & S_IFMT ) == mask; 1569 } 1570 } 1571 1572 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); } 1573 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); } 1574 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); } 1575 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); } 1576 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); } 1577 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } 1578 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } 1579 } 1580 else version (FreeBSD) 1581 { 1582 enum S_IRUSR = 0x100; // octal 0000400 1583 enum S_IWUSR = 0x080; // octal 0000200 1584 enum S_IXUSR = 0x040; // octal 0000100 1585 enum S_IRWXU = 0x1C0; // octal 0000700 1586 1587 enum S_IRGRP = 0x020; // octal 0000040 1588 enum S_IWGRP = 0x010; // octal 0000020 1589 enum S_IXGRP = 0x008; // octal 0000010 1590 enum S_IRWXG = 0x038; // octal 0000070 1591 1592 enum S_IROTH = 0x4; // 0000004 1593 enum S_IWOTH = 0x2; // 0000002 1594 enum S_IXOTH = 0x1; // 0000001 1595 enum S_IRWXO = 0x7; // 0000007 1596 1597 private 1598 { 1599 extern (D) bool S_ISTYPE( mode_t mode, uint mask ) 1600 { 1601 return ( mode & S_IFMT ) == mask; 1602 } 1603 } 1604 1605 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); } 1606 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); } 1607 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); } 1608 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); } 1609 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); } 1610 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } 1611 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } 1612 1613 // Since FreeBSD 11: 1614 version (none) 1615 { 1616 int utimensat(int dirfd, const char *pathname, 1617 ref const(timespec)[2] times, int flags); 1618 int futimens(int fd, ref const(timespec)[2] times); 1619 } 1620 } 1621 else version (NetBSD) 1622 { 1623 enum S_IRUSR = 0x100; // octal 0000400 1624 enum S_IWUSR = 0x080; // octal 0000200 1625 enum S_IXUSR = 0x040; // octal 0000100 1626 enum S_IRWXU = 0x1C0; // octal 0000700 1627 1628 enum S_IRGRP = 0x020; // octal 0000040 1629 enum S_IWGRP = 0x010; // octal 0000020 1630 enum S_IXGRP = 0x008; // octal 0000010 1631 enum S_IRWXG = 0x038; // octal 0000070 1632 1633 enum S_IROTH = 0x4; // 0000004 1634 enum S_IWOTH = 0x2; // 0000002 1635 enum S_IXOTH = 0x1; // 0000001 1636 enum S_IRWXO = 0x7; // 0000007 1637 1638 private 1639 { 1640 extern (D) bool S_ISTYPE( mode_t mode, uint mask ) 1641 { 1642 return ( mode & S_IFMT ) == mask; 1643 } 1644 } 1645 1646 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); } 1647 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); } 1648 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); } 1649 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); } 1650 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); } 1651 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } 1652 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } 1653 } 1654 else version (OpenBSD) 1655 { 1656 enum S_IRUSR = 0x100; // octal 0000400 1657 enum S_IWUSR = 0x080; // octal 0000200 1658 enum S_IXUSR = 0x040; // octal 0000100 1659 enum S_IRWXU = 0x1C0; // octal 0000700 1660 1661 enum S_IRGRP = 0x020; // octal 0000040 1662 enum S_IWGRP = 0x010; // octal 0000020 1663 enum S_IXGRP = 0x008; // octal 0000010 1664 enum S_IRWXG = 0x038; // octal 0000070 1665 1666 enum S_IROTH = 0x4; // 0000004 1667 enum S_IWOTH = 0x2; // 0000002 1668 enum S_IXOTH = 0x1; // 0000001 1669 enum S_IRWXO = 0x7; // 0000007 1670 1671 extern (D) bool S_ISBLK(mode_t mode) { return (mode & S_IFMT) == S_IFBLK; } 1672 extern (D) bool S_ISCHR(mode_t mode) { return (mode & S_IFMT) == S_IFCHR; } 1673 extern (D) bool S_ISDIR(mode_t mode) { return (mode & S_IFMT) == S_IFDIR; } 1674 extern (D) bool S_ISFIFO(mode_t mode) { return (mode & S_IFMT) == S_IFIFO; } 1675 extern (D) bool S_ISREG(mode_t mode) { return (mode & S_IFMT) == S_IFREG; } 1676 extern (D) bool S_ISLNK(mode_t mode) { return (mode & S_IFMT) == S_IFLNK; } 1677 extern (D) bool S_ISSOCK(mode_t mode) { return (mode & S_IFMT) == S_IFSOCK; } 1678 } 1679 else version (DragonFlyBSD) 1680 { 1681 enum S_IRUSR = 0x100; // octal 0000400 1682 enum S_IWUSR = 0x080; // octal 0000200 1683 enum S_IXUSR = 0x040; // octal 0000100 1684 enum S_IRWXU = 0x1C0; // octal 0000700 1685 1686 enum S_IRGRP = 0x020; // octal 0000040 1687 enum S_IWGRP = 0x010; // octal 0000020 1688 enum S_IXGRP = 0x008; // octal 0000010 1689 enum S_IRWXG = 0x038; // octal 0000070 1690 1691 enum S_IROTH = 0x4; // 0000004 1692 enum S_IWOTH = 0x2; // 0000002 1693 enum S_IXOTH = 0x1; // 0000001 1694 enum S_IRWXO = 0x7; // 0000007 1695 1696 private 1697 { 1698 extern (D) bool S_ISTYPE( mode_t mode, uint mask ) 1699 { 1700 return ( mode & S_IFMT ) == mask; 1701 } 1702 } 1703 1704 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); } 1705 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); } 1706 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); } 1707 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); } 1708 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); } 1709 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } 1710 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } 1711 } 1712 else version (Solaris) 1713 { 1714 enum S_IRUSR = 0x100; 1715 enum S_IWUSR = 0x080; 1716 enum S_IXUSR = 0x040; 1717 enum S_IRWXU = 0x1C0; 1718 1719 enum S_IRGRP = 0x020; 1720 enum S_IWGRP = 0x010; 1721 enum S_IXGRP = 0x008; 1722 enum S_IRWXG = 0x038; 1723 1724 enum S_IROTH = 0x4; // 0000004 1725 enum S_IWOTH = 0x2; // 0000002 1726 enum S_IXOTH = 0x1; // 0000001 1727 enum S_IRWXO = 0x7; // 0000007 1728 1729 private 1730 { 1731 extern (D) bool S_ISTYPE(mode_t mode, uint mask) 1732 { 1733 return (mode & S_IFMT) == mask; 1734 } 1735 } 1736 1737 extern (D) bool S_ISBLK(mode_t mode) { return S_ISTYPE(mode, S_IFBLK); } 1738 extern (D) bool S_ISCHR(mode_t mode) { return S_ISTYPE(mode, S_IFCHR); } 1739 extern (D) bool S_ISDIR(mode_t mode) { return S_ISTYPE(mode, S_IFDIR); } 1740 extern (D) bool S_ISFIFO(mode_t mode) { return S_ISTYPE(mode, S_IFIFO); } 1741 extern (D) bool S_ISREG(mode_t mode) { return S_ISTYPE(mode, S_IFREG); } 1742 extern (D) bool S_ISLNK(mode_t mode) { return S_ISTYPE(mode, S_IFLNK); } 1743 extern (D) bool S_ISSOCK(mode_t mode) { return S_ISTYPE(mode, S_IFSOCK); } 1744 extern (D) bool S_ISDOOR(mode_t mode) { return S_ISTYPE(mode, S_IFDOOR); } 1745 extern (D) bool S_ISPORT(mode_t mode) { return S_ISTYPE(mode, S_IFPORT); } 1746 } 1747 else version (CRuntime_Bionic) 1748 { 1749 enum S_IRUSR = 0x100; // octal 0000400 1750 enum S_IWUSR = 0x080; // octal 0000200 1751 enum S_IXUSR = 0x040; // octal 0000100 1752 enum S_IRWXU = 0x1C0; // octal 0000700 1753 1754 enum S_IRGRP = 0x020; // octal 0000040 1755 enum S_IWGRP = 0x010; // octal 0000020 1756 enum S_IXGRP = 0x008; // octal 0000010 1757 enum S_IRWXG = 0x038; // octal 0000070 1758 1759 enum S_IROTH = 0x4; // 0000004 1760 enum S_IWOTH = 0x2; // 0000002 1761 enum S_IXOTH = 0x1; // 0000001 1762 enum S_IRWXO = 0x7; // 0000007 1763 1764 private 1765 { 1766 extern (D) bool S_ISTYPE( uint mode, uint mask ) 1767 { 1768 return ( mode & S_IFMT ) == mask; 1769 } 1770 } 1771 1772 extern (D) bool S_ISBLK( uint mode ) { return S_ISTYPE( mode, S_IFBLK ); } 1773 extern (D) bool S_ISCHR( uint mode ) { return S_ISTYPE( mode, S_IFCHR ); } 1774 extern (D) bool S_ISDIR( uint mode ) { return S_ISTYPE( mode, S_IFDIR ); } 1775 extern (D) bool S_ISFIFO( uint mode ) { return S_ISTYPE( mode, S_IFIFO ); } 1776 extern (D) bool S_ISREG( uint mode ) { return S_ISTYPE( mode, S_IFREG ); } 1777 extern (D) bool S_ISLNK( uint mode ) { return S_ISTYPE( mode, S_IFLNK ); } 1778 extern (D) bool S_ISSOCK( uint mode ) { return S_ISTYPE( mode, S_IFSOCK ); } 1779 1780 // Added since Lollipop 1781 int utimensat(int dirfd, const char *pathname, 1782 ref const(timespec)[2] times, int flags); 1783 } 1784 else version (CRuntime_Musl) 1785 { 1786 enum { 1787 S_IRUSR = 0x100, // octal 0400 1788 S_IWUSR = 0x080, // octal 0200 1789 S_IXUSR = 0x040, // octal 0100 1790 S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR, 1791 1792 S_IRGRP = S_IRUSR >> 3, 1793 S_IWGRP = S_IWUSR >> 3, 1794 S_IXGRP = S_IXUSR >> 3, 1795 S_IRWXG = S_IRWXU >> 3, 1796 1797 S_IROTH = S_IRGRP >> 3, 1798 S_IWOTH = S_IWGRP >> 3, 1799 S_IXOTH = S_IXGRP >> 3, 1800 S_IRWXO = S_IRWXG >> 3, 1801 } 1802 1803 private 1804 { 1805 extern (D) bool S_ISTYPE( mode_t mode, uint mask ) 1806 { 1807 return ( mode & S_IFMT ) == mask; 1808 } 1809 } 1810 1811 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); } 1812 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); } 1813 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); } 1814 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); } 1815 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); } 1816 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } 1817 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } 1818 1819 int utimensat(int dirfd, const char *pathname, 1820 ref const(timespec)[2] times, int flags); 1821 } 1822 else version (CRuntime_UClibc) 1823 { 1824 enum S_IRUSR = 0x100; // octal 0400 1825 enum S_IWUSR = 0x080; // octal 0200 1826 enum S_IXUSR = 0x040; // octal 0100 1827 enum S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR; 1828 1829 enum S_IRGRP = S_IRUSR >> 3; 1830 enum S_IWGRP = S_IWUSR >> 3; 1831 enum S_IXGRP = S_IXUSR >> 3; 1832 enum S_IRWXG = S_IRWXU >> 3; 1833 1834 enum S_IROTH = S_IRGRP >> 3; 1835 enum S_IWOTH = S_IWGRP >> 3; 1836 enum S_IXOTH = S_IXGRP >> 3; 1837 enum S_IRWXO = S_IRWXG >> 3; 1838 1839 private 1840 { 1841 extern (D) bool S_ISTYPE( mode_t mode, uint mask ) 1842 { 1843 return ( mode & S_IFMT ) == mask; 1844 } 1845 } 1846 1847 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); } 1848 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); } 1849 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); } 1850 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); } 1851 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); } 1852 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); } 1853 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); } 1854 1855 int utimensat(int dirfd, const char *pathname, 1856 ref const(timespec)[2] times, int flags); 1857 int futimens(int fd, ref const(timespec)[2] times); 1858 } 1859 else 1860 { 1861 static assert(false, "Unsupported platform"); 1862 } 1863 1864 /* 1865 int chmod(const scope char*, mode_t); 1866 int fchmod(int, mode_t); 1867 int fstat(int, stat*); 1868 int lstat(const scope char*, stat*); 1869 int mkdir(const scope char*, mode_t); 1870 int mkfifo(const scope char*, mode_t); 1871 int stat(const scope char*, stat*); 1872 mode_t umask(mode_t); 1873 */ 1874 1875 int chmod(const scope char*, mode_t); 1876 int fchmod(int, mode_t); 1877 //int fstat(int, stat_t*); 1878 //int lstat(const scope char*, stat_t*); 1879 int mkdir(const scope char*, mode_t); 1880 int mkfifo(const scope char*, mode_t); 1881 //int stat(const scope char*, stat_t*); 1882 mode_t umask(mode_t); 1883 1884 version (CRuntime_Glibc) 1885 { 1886 static if ( __USE_LARGEFILE64 ) 1887 { 1888 int fstat64(int, stat_t*) @trusted; 1889 alias fstat64 fstat; 1890 1891 int lstat64(const scope char*, stat_t*); 1892 alias lstat64 lstat; 1893 1894 int stat64(const scope char*, stat_t*); 1895 alias stat64 stat; 1896 } 1897 else 1898 { 1899 int fstat(int, stat_t*) @trusted; 1900 int lstat(const scope char*, stat_t*); 1901 int stat(const scope char*, stat_t*); 1902 } 1903 } 1904 else version (Solaris) 1905 { 1906 version (D_LP64) 1907 { 1908 int fstat(int, stat_t*) @trusted; 1909 int lstat(const scope char*, stat_t*); 1910 int stat(const scope char*, stat_t*); 1911 1912 static if (__USE_LARGEFILE64) 1913 { 1914 alias fstat fstat64; 1915 alias lstat lstat64; 1916 alias stat stat64; 1917 } 1918 } 1919 else 1920 { 1921 static if (__USE_LARGEFILE64) 1922 { 1923 int fstat64(int, stat_t*) @trusted; 1924 alias fstat64 fstat; 1925 1926 int lstat64(const scope char*, stat_t*); 1927 alias lstat64 lstat; 1928 1929 int stat64(const scope char*, stat_t*); 1930 alias stat64 stat; 1931 } 1932 else 1933 { 1934 int fstat(int, stat_t*) @trusted; 1935 int lstat(const scope char*, stat_t*); 1936 int stat(const scope char*, stat_t*); 1937 } 1938 } 1939 } 1940 else version (Darwin) 1941 { 1942 // OS X maintains backwards compatibility with older binaries using 32-bit 1943 // inode functions by appending $INODE64 to newer 64-bit inode functions. 1944 version (OSX) 1945 { 1946 version (AArch64) 1947 { 1948 int fstat(int, stat_t*); 1949 int lstat(const scope char*, stat_t*); 1950 int stat(const scope char*, stat_t*); 1951 } 1952 else 1953 { 1954 pragma(mangle, "fstat$INODE64") int fstat(int, stat_t*); 1955 pragma(mangle, "lstat$INODE64") int lstat(const scope char*, stat_t*); 1956 pragma(mangle, "stat$INODE64") int stat(const scope char*, stat_t*); 1957 } 1958 } 1959 else 1960 { 1961 int fstat(int, stat_t*); 1962 int lstat(const scope char*, stat_t*); 1963 int stat(const scope char*, stat_t*); 1964 } 1965 } 1966 else version (FreeBSD) 1967 { 1968 version (GNU) 1969 { 1970 int fstat(int, stat_t*); 1971 int lstat(const scope char*, stat_t*); 1972 int stat(const scope char*, stat_t*); 1973 } 1974 else 1975 { 1976 static if (__FreeBSD_version >= INO64_FIRST) 1977 { 1978 pragma(mangle, "fstat@FBSD_1.5") int fstat(int, stat_t*); 1979 pragma(mangle, "lstat@FBSD_1.5") int lstat(const scope char*, stat_t*); 1980 pragma(mangle, "stat@FBSD_1.5") int stat(const scope char*, stat_t*); 1981 } 1982 else 1983 { 1984 pragma(mangle, "fstat@FBSD_1.0") int fstat(int, stat_t*); 1985 pragma(mangle, "lstat@FBSD_1.0") int lstat(const scope char*, stat_t*); 1986 pragma(mangle, "stat@FBSD_1.0") int stat(const scope char*, stat_t*); 1987 } 1988 } 1989 } 1990 else version (NetBSD) 1991 { 1992 int __fstat50(int, stat_t*); 1993 int __lstat50(const scope char*, stat_t*); 1994 int __stat50(const scope char*, stat_t*); 1995 alias __fstat50 fstat; 1996 alias __lstat50 lstat; 1997 alias __stat50 stat; 1998 } 1999 else version (OpenBSD) 2000 { 2001 int fstat(int, stat_t*); 2002 int lstat(const scope char*, stat_t*); 2003 int stat(const scope char*, stat_t*); 2004 } 2005 else version (DragonFlyBSD) 2006 { 2007 int fstat(int, stat_t*); 2008 int lstat(const scope char*, stat_t*); 2009 int stat(const scope char*, stat_t*); 2010 } 2011 else version (CRuntime_Bionic) 2012 { 2013 int fstat(int, stat_t*) @trusted; 2014 int lstat(const scope char*, stat_t*); 2015 int stat(const scope char*, stat_t*); 2016 } 2017 else version (CRuntime_Musl) 2018 { 2019 pragma(mangle, muslRedirTime64Mangle!("stat", "__stat_time64")) 2020 int stat(const scope char*, stat_t*); 2021 pragma(mangle, muslRedirTime64Mangle!("fstat", "__fstat_time64")) 2022 int fstat(int, stat_t*); 2023 pragma(mangle, muslRedirTime64Mangle!("lstat", "__lstat_time64")) 2024 int lstat(const scope char*, stat_t*); 2025 2026 alias fstat fstat64; 2027 alias lstat lstat64; 2028 alias stat stat64; 2029 } 2030 else version (CRuntime_UClibc) 2031 { 2032 static if ( __USE_LARGEFILE64 ) 2033 { 2034 int fstat64(int, stat_t*) @trusted; 2035 alias fstat64 fstat; 2036 2037 int lstat64(const scope char*, stat_t*); 2038 alias lstat64 lstat; 2039 2040 int stat64(const scope char*, stat_t*); 2041 alias stat64 stat; 2042 } 2043 else 2044 { 2045 int fstat(int, stat_t*) @trusted; 2046 int lstat(const scope char*, stat_t*); 2047 int stat(const scope char*, stat_t*); 2048 } 2049 } 2050 2051 // 2052 // Typed Memory Objects (TYM) 2053 // 2054 /* 2055 S_TYPEISTMO(buf) 2056 */ 2057 2058 // 2059 // XOpen (XSI) 2060 // 2061 /* 2062 S_IFMT 2063 S_IFBLK 2064 S_IFCHR 2065 S_IFIFO 2066 S_IFREG 2067 S_IFDIR 2068 S_IFLNK 2069 S_IFSOCK 2070 */ 2071 2072 version (linux) 2073 { 2074 enum S_IFMT = 0xF000; // octal 0170000 2075 enum S_IFBLK = 0x6000; // octal 0060000 2076 enum S_IFCHR = 0x2000; // octal 0020000 2077 enum S_IFIFO = 0x1000; // octal 0010000 2078 enum S_IFREG = 0x8000; // octal 0100000 2079 enum S_IFDIR = 0x4000; // octal 0040000 2080 enum S_IFLNK = 0xA000; // octal 0120000 2081 enum S_IFSOCK = 0xC000; // octal 0140000 2082 } 2083 else version (Darwin) 2084 { 2085 enum S_IFMT = 0xF000; // octal 0170000 2086 enum S_IFBLK = 0x6000; // octal 0060000 2087 enum S_IFCHR = 0x2000; // octal 0020000 2088 enum S_IFIFO = 0x1000; // octal 0010000 2089 enum S_IFREG = 0x8000; // octal 0100000 2090 enum S_IFDIR = 0x4000; // octal 0040000 2091 enum S_IFLNK = 0xA000; // octal 0120000 2092 enum S_IFSOCK = 0xC000; // octal 0140000 2093 } 2094 else version (FreeBSD) 2095 { 2096 enum S_IFMT = 0xF000; // octal 0170000 2097 enum S_IFBLK = 0x6000; // octal 0060000 2098 enum S_IFCHR = 0x2000; // octal 0020000 2099 enum S_IFIFO = 0x1000; // octal 0010000 2100 enum S_IFREG = 0x8000; // octal 0100000 2101 enum S_IFDIR = 0x4000; // octal 0040000 2102 enum S_IFLNK = 0xA000; // octal 0120000 2103 enum S_IFSOCK = 0xC000; // octal 0140000 2104 } 2105 else version (NetBSD) 2106 { 2107 enum S_IFMT = 0xF000; // octal 0170000 2108 enum S_IFBLK = 0x6000; // octal 0060000 2109 enum S_IFCHR = 0x2000; // octal 0020000 2110 enum S_IFIFO = 0x1000; // octal 0010000 2111 enum S_IFREG = 0x8000; // octal 0100000 2112 enum S_IFDIR = 0x4000; // octal 0040000 2113 enum S_IFLNK = 0xA000; // octal 0120000 2114 enum S_IFSOCK = 0xC000; // octal 0140000 2115 } 2116 else version (OpenBSD) 2117 { 2118 enum S_IFMT = 0xF000; // octal 0170000 2119 enum S_IFBLK = 0x6000; // octal 0060000 2120 enum S_IFCHR = 0x2000; // octal 0020000 2121 enum S_IFIFO = 0x1000; // octal 0010000 2122 enum S_IFREG = 0x8000; // octal 0100000 2123 enum S_IFDIR = 0x4000; // octal 0040000 2124 enum S_IFLNK = 0xA000; // octal 0120000 2125 enum S_IFSOCK = 0xC000; // octal 0140000 2126 } 2127 else version (DragonFlyBSD) 2128 { 2129 enum S_IFMT = 0xF000; // octal 0170000 2130 enum S_IFBLK = 0x6000; // octal 0060000 2131 enum S_IFCHR = 0x2000; // octal 0020000 2132 enum S_IFIFO = 0x1000; // octal 0010000 2133 enum S_IFREG = 0x8000; // octal 0100000 2134 enum S_IFDIR = 0x4000; // octal 0040000 2135 enum S_IFLNK = 0xA000; // octal 0120000 2136 enum S_IFSOCK = 0xC000; // octal 0140000 2137 } 2138 else version (Solaris) 2139 { 2140 enum S_IFMT = 0xF000; 2141 enum S_IFBLK = 0x6000; 2142 enum S_IFCHR = 0x2000; 2143 enum S_IFIFO = 0x1000; 2144 enum S_IFREG = 0x8000; 2145 enum S_IFDIR = 0x4000; 2146 enum S_IFLNK = 0xA000; 2147 enum S_IFSOCK = 0xC000; 2148 enum S_IFDOOR = 0xD000; 2149 enum S_IFPORT = 0xE000; 2150 } 2151 else 2152 { 2153 static assert(false, "Unsupported platform"); 2154 } 2155 2156 /* 2157 int mknod(const scope char*, mode_t, dev_t); 2158 */ 2159 2160 version (CRuntime_Glibc) 2161 { 2162 int mknod(const scope char*, mode_t, dev_t); 2163 } 2164 else version (Darwin) 2165 { 2166 int mknod(const scope char*, mode_t, dev_t); 2167 } 2168 else version (FreeBSD) 2169 { 2170 version (GNU) 2171 { 2172 int mknod(const scope char*, mode_t, dev_t); 2173 } 2174 else 2175 { 2176 static if (__FreeBSD_version >= INO64_FIRST) 2177 pragma(mangle, "mknod@FBSD_1.5") int mknod(const scope char*, mode_t, dev_t); 2178 else 2179 pragma(mangle, "mknod@FBSD_1.0") int mknod(const scope char*, mode_t, dev_t); 2180 } 2181 } 2182 else version (NetBSD) 2183 { 2184 int mknod(const scope char*, mode_t, dev_t); 2185 } 2186 else version (OpenBSD) 2187 { 2188 int mknod(const scope char*, mode_t, dev_t); 2189 } 2190 else version (DragonFlyBSD) 2191 { 2192 int mknod(const scope char*, mode_t, dev_t); 2193 } 2194 else version (Solaris) 2195 { 2196 int mknod(const scope char*, mode_t, dev_t); 2197 } 2198 else version (CRuntime_Bionic) 2199 { 2200 int mknod(const scope char*, mode_t, dev_t); 2201 } 2202 else version (CRuntime_Musl) 2203 { 2204 int mknod(const scope char*, mode_t, dev_t); 2205 } 2206 else version (CRuntime_UClibc) 2207 { 2208 int mknod(const scope char*, mode_t, dev_t); 2209 } 2210 else 2211 { 2212 static assert(false, "Unsupported platform"); 2213 }