1 2 /** 3 * This file has no copyright assigned and is placed in the Public Domain. 4 * This file is part of the w64 mingw-runtime package. 5 * No warranty is given; refer to the file DISCLAIMER within this package. 6 */ 7 #ifndef _IO_H_ 8 #define _IO_H_ 9 10 #include <corecrt.h> 11 #include <string.h> 12 13 #pragma pack(push,_CRT_PACKING) 14 15 #ifndef _POSIX_ 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 _Check_return_ 22 _Ret_opt_z_ 23 _CRTIMP 24 char* 25 __cdecl 26 _getcwd( 27 _Out_writes_opt_(_SizeInBytes) char *_DstBuf, 28 _In_ int _SizeInBytes); 29 30 #ifndef _FSIZE_T_DEFINED 31 typedef unsigned long _fsize_t; 32 #define _FSIZE_T_DEFINED 33 #endif 34 35 #ifndef _FINDDATA_T_DEFINED 36 37 struct _finddata_t { 38 unsigned attrib; 39 time_t time_create; 40 time_t time_access; 41 time_t time_write; 42 _fsize_t size; 43 char name[260]; 44 }; 45 46 struct _finddata32_t { 47 unsigned attrib; 48 __time32_t time_create; 49 __time32_t time_access; 50 __time32_t time_write; 51 _fsize_t size; 52 char name[260]; 53 }; 54 55 #if _INTEGRAL_MAX_BITS >= 64 56 57 struct _finddatai64_t { 58 unsigned attrib; 59 time_t time_create; 60 time_t time_access; 61 time_t time_write; 62 __MINGW_EXTENSION __int64 size; 63 char name[260]; 64 }; 65 66 struct _finddata32i64_t { 67 unsigned attrib; 68 __time32_t time_create; 69 __time32_t time_access; 70 __time32_t time_write; 71 __MINGW_EXTENSION __int64 size; 72 char name[260]; 73 }; 74 75 struct _finddata64i32_t { 76 unsigned attrib; 77 __time64_t time_create; 78 __time64_t time_access; 79 __time64_t time_write; 80 _fsize_t size; 81 char name[260]; 82 }; 83 84 struct __finddata64_t { 85 unsigned attrib; 86 __time64_t time_create; 87 __time64_t time_access; 88 __time64_t time_write; 89 __MINGW_EXTENSION __int64 size; 90 char name[260]; 91 }; 92 #endif /* _INTEGRAL_MAX_BITS >= 64 */ 93 94 #define _FINDDATA_T_DEFINED 95 #endif 96 97 #ifndef _WFINDDATA_T_DEFINED 98 99 struct _wfinddata_t { 100 unsigned attrib; 101 time_t time_create; 102 time_t time_access; 103 time_t time_write; 104 _fsize_t size; 105 wchar_t name[260]; 106 }; 107 108 struct _wfinddata32_t { 109 unsigned attrib; 110 __time32_t time_create; 111 __time32_t time_access; 112 __time32_t time_write; 113 _fsize_t size; 114 wchar_t name[260]; 115 }; 116 117 #if _INTEGRAL_MAX_BITS >= 64 118 119 struct _wfinddatai64_t { 120 unsigned attrib; 121 time_t time_create; 122 time_t time_access; 123 time_t time_write; 124 __MINGW_EXTENSION __int64 size; 125 wchar_t name[260]; 126 }; 127 128 struct _wfinddata32i64_t { 129 unsigned attrib; 130 __time32_t time_create; 131 __time32_t time_access; 132 __time32_t time_write; 133 __MINGW_EXTENSION __int64 size; 134 wchar_t name[260]; 135 }; 136 137 struct _wfinddata64i32_t { 138 unsigned attrib; 139 __time64_t time_create; 140 __time64_t time_access; 141 __time64_t time_write; 142 _fsize_t size; 143 wchar_t name[260]; 144 }; 145 146 struct _wfinddata64_t { 147 unsigned attrib; 148 __time64_t time_create; 149 __time64_t time_access; 150 __time64_t time_write; 151 __MINGW_EXTENSION __int64 size; 152 wchar_t name[260]; 153 }; 154 #endif 155 156 #define _WFINDDATA_T_DEFINED 157 #endif 158 159 #define _A_NORMAL 0x00 160 #define _A_RDONLY 0x01 161 #define _A_HIDDEN 0x02 162 #define _A_SYSTEM 0x04 163 #define _A_SUBDIR 0x10 164 #define _A_ARCH 0x20 165 166 /* Some defines for _access nAccessMode (MS doesn't define them, but 167 * it doesn't seem to hurt to add them). */ 168 #define F_OK 0 /* Check for file existence */ 169 #define X_OK 1 /* Check for execute permission. */ 170 #define W_OK 2 /* Check for write permission */ 171 #define R_OK 4 /* Check for read permission */ 172 173 _Check_return_ 174 _CRTIMP 175 int 176 __cdecl 177 _access( 178 _In_z_ const char *_Filename, 179 _In_ int _AccessMode); 180 181 _Check_return_ 182 _CRTIMP 183 int 184 __cdecl 185 _chmod( 186 _In_z_ const char *_Filename, 187 _In_ int _Mode); 188 189 _Check_return_ 190 _CRTIMP 191 int 192 __cdecl 193 _chsize( 194 _In_ int _FileHandle, 195 _In_ long _Size); 196 197 _Check_return_opt_ 198 _CRTIMP 199 int 200 __cdecl 201 _close( 202 _In_ int _FileHandle); 203 204 _Check_return_opt_ 205 _CRTIMP 206 int 207 __cdecl 208 _commit( 209 _In_ int _FileHandle); 210 211 _Check_return_ 212 _CRTIMP 213 int 214 __cdecl 215 _creat( 216 _In_z_ const char *_Filename, 217 _In_ int _PermissionMode); 218 219 _Check_return_ 220 _CRTIMP 221 int 222 __cdecl 223 _dup( 224 _In_ int _FileHandle); 225 226 _Check_return_ 227 _CRTIMP 228 int 229 __cdecl 230 _dup2( 231 _In_ int _FileHandleSrc, 232 _In_ int _FileHandleDst); 233 234 _Check_return_ 235 _CRTIMP 236 int 237 __cdecl 238 _eof( 239 _In_ int _FileHandle); 240 241 _Check_return_ 242 _CRTIMP 243 long 244 __cdecl 245 _filelength( 246 _In_ int _FileHandle); 247 248 _CRTIMP 249 intptr_t 250 __cdecl 251 _findfirst( 252 const char *_Filename, 253 struct _finddata_t *_FindData); 254 255 _Check_return_ 256 _CRTIMP 257 intptr_t 258 __cdecl 259 _findfirst32( 260 _In_z_ const char *_Filename, 261 _Out_ struct _finddata32_t *_FindData); 262 263 _CRTIMP 264 int 265 __cdecl 266 _findnext( 267 intptr_t _FindHandle, 268 struct _finddata_t *_FindData); 269 270 _Check_return_ 271 _CRTIMP 272 int 273 __cdecl 274 _findnext32( 275 _In_ intptr_t _FindHandle, 276 _Out_ struct _finddata32_t *_FindData); 277 278 _Check_return_opt_ 279 _CRTIMP 280 int 281 __cdecl 282 _findclose( 283 _In_ intptr_t _FindHandle); 284 285 _Check_return_ 286 _CRTIMP 287 int 288 __cdecl 289 _isatty( 290 _In_ int _FileHandle); 291 292 _CRTIMP 293 int 294 __cdecl 295 _locking( 296 _In_ int _FileHandle, 297 _In_ int _LockMode, 298 _In_ long _NumOfBytes); 299 300 _Check_return_opt_ 301 _CRTIMP 302 long 303 __cdecl 304 _lseek( 305 _In_ int _FileHandle, 306 _In_ long _Offset, 307 _In_ int _Origin); 308 309 _Check_return_ 310 _CRTIMP 311 char* 312 __cdecl 313 _mktemp( 314 _Inout_z_ char *_TemplateName); 315 316 _Check_return_ 317 _CRTIMP 318 int 319 __cdecl 320 _pipe( 321 _Inout_updates_(2) int *_PtHandles, 322 _In_ unsigned int _PipeSize, 323 _In_ int _TextMode); 324 325 _Check_return_ 326 _CRTIMP 327 int 328 __cdecl 329 _read( 330 _In_ int _FileHandle, 331 _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, 332 _In_ unsigned int _MaxCharCount); 333 334 #ifndef _CRT_DIRECTORY_DEFINED 335 #define _CRT_DIRECTORY_DEFINED 336 337 _Check_return_ 338 int 339 __cdecl 340 remove( 341 _In_z_ const char *_Filename); 342 343 _Check_return_ 344 int 345 __cdecl 346 rename( 347 _In_z_ const char *_OldFilename, 348 _In_z_ const char *_NewFilename); 349 350 _Check_return_ 351 _CRTIMP 352 int 353 __cdecl 354 _unlink( 355 _In_z_ const char *_Filename); 356 357 #ifndef NO_OLDNAMES 358 _Check_return_ 359 _CRTIMP 360 int 361 __cdecl 362 unlink( 363 _In_z_ const char *_Filename); 364 #endif 365 366 #endif /* _CRT_DIRECTORY_DEFINED */ 367 368 _Check_return_ 369 _CRTIMP 370 int 371 __cdecl 372 _setmode( 373 _In_ int _FileHandle, 374 _In_ int _Mode); 375 376 _Check_return_ 377 _CRTIMP 378 long 379 __cdecl 380 _tell( 381 _In_ int _FileHandle); 382 383 _CRTIMP 384 int 385 __cdecl 386 _umask( 387 _In_ int _Mode); 388 389 _CRTIMP 390 int 391 __cdecl 392 _write( 393 _In_ int _FileHandle, 394 _In_reads_bytes_(_MaxCharCount) const void *_Buf, 395 _In_ unsigned int _MaxCharCount); 396 397 #if _INTEGRAL_MAX_BITS >= 64 398 399 __MINGW_EXTENSION 400 _Check_return_ 401 _CRTIMP 402 __int64 403 __cdecl 404 _filelengthi64( 405 _In_ int _FileHandle); 406 407 _Check_return_ 408 _CRTIMP 409 intptr_t 410 __cdecl 411 _findfirst32i64( 412 _In_z_ const char *_Filename, 413 _Out_ struct _finddata32i64_t *_FindData); 414 415 _Check_return_ 416 _CRTIMP 417 intptr_t 418 __cdecl 419 _findfirst64i32( 420 _In_z_ const char *_Filename, 421 _Out_ struct _finddata64i32_t *_FindData); 422 423 _Check_return_ 424 _CRTIMP 425 intptr_t 426 __cdecl 427 _findfirst64( 428 _In_z_ const char *_Filename, 429 _Out_ struct __finddata64_t *_FindData); 430 431 _Check_return_ 432 _CRTIMP 433 int 434 __cdecl 435 _findnext32i64( 436 _In_ intptr_t _FindHandle, 437 _Out_ struct _finddata32i64_t *_FindData); 438 439 _Check_return_ 440 _CRTIMP 441 int 442 __cdecl 443 _findnext64i32( 444 _In_ intptr_t _FindHandle, 445 _Out_ struct _finddata64i32_t *_FindData); 446 447 _Check_return_ 448 _CRTIMP 449 int 450 __cdecl 451 _findnext64( 452 _In_ intptr_t _FindHandle, 453 _Out_ struct __finddata64_t *_FindData); 454 455 __MINGW_EXTENSION 456 _Check_return_opt_ 457 _CRTIMP 458 __int64 459 __cdecl 460 _lseeki64( 461 _In_ int _FileHandle, 462 _In_ __int64 _Offset, 463 _In_ int _Origin); 464 465 __MINGW_EXTENSION 466 _Check_return_ 467 _CRTIMP 468 __int64 469 __cdecl 470 _telli64( 471 _In_ int _FileHandle); 472 473 #ifdef __cplusplus 474 #include <string.h> 475 #endif 476 477 _Check_return_ 478 __CRT_INLINE 479 intptr_t 480 __cdecl 481 _findfirst64i32( 482 const char *_Filename, 483 struct _finddata64i32_t *_FindData) 484 { 485 struct __finddata64_t fd; 486 intptr_t ret = _findfirst64(_Filename,&fd); 487 _FindData->attrib=fd.attrib; 488 _FindData->time_create=fd.time_create; 489 _FindData->time_access=fd.time_access; 490 _FindData->time_write=fd.time_write; 491 _FindData->size=(_fsize_t) fd.size; 492 strncpy(_FindData->name,fd.name,260); 493 return ret; 494 } 495 496 _Check_return_ 497 __CRT_INLINE 498 int 499 __cdecl 500 _findnext64i32( 501 intptr_t _FindHandle, 502 struct _finddata64i32_t *_FindData) 503 { 504 struct __finddata64_t fd; 505 int ret = _findnext64(_FindHandle,&fd); 506 _FindData->attrib=fd.attrib; 507 _FindData->time_create=fd.time_create; 508 _FindData->time_access=fd.time_access; 509 _FindData->time_write=fd.time_write; 510 _FindData->size=(_fsize_t) fd.size; 511 strncpy(_FindData->name,fd.name,260); 512 return ret; 513 } 514 515 #endif /* _INTEGRAL_MAX_BITS >= 64 */ 516 517 #ifndef NO_OLDNAMES 518 #ifndef _UWIN 519 520 _Check_return_ 521 _CRTIMP 522 int 523 __cdecl 524 chdir( 525 _In_z_ const char *_Path); 526 527 _Check_return_ 528 _Ret_opt_z_ 529 _CRTIMP 530 char* 531 __cdecl 532 getcwd( 533 _Out_writes_opt_(_SizeInBytes) char *_DstBuf, 534 _In_ int _SizeInBytes); 535 536 _Check_return_ 537 _CRTIMP 538 int 539 __cdecl 540 mkdir( 541 _In_z_ const char *_Path); 542 543 _CRTIMP 544 char* 545 __cdecl 546 mktemp( 547 _Inout_z_ char *_TemplateName); 548 549 _Check_return_ 550 _CRTIMP 551 int 552 __cdecl 553 rmdir( 554 _In_z_ const char *_Path); 555 556 _Check_return_ 557 _CRTIMP 558 int 559 __cdecl 560 chmod( 561 _In_z_ const char *_Filename, 562 _In_ int _AccessMode); 563 564 #endif /* _UWIN */ 565 #endif /* Not NO_OLDNAMES */ 566 567 _Check_return_wat_ 568 _CRTIMP 569 errno_t 570 __cdecl 571 _sopen_s( 572 _Out_ int *_FileHandle, 573 _In_z_ const char *_Filename, 574 _In_ int _OpenFlag, 575 _In_ int _ShareFlag, 576 _In_ int _PermissionMode); 577 578 #ifndef __cplusplus 579 _CRTIMP int __cdecl _open(const char *_Filename,int _OpenFlag,...); 580 _CRTIMP int __cdecl _sopen(const char *_Filename,int _OpenFlag,int _ShareFlag,...); 581 #else 582 extern "C++" _CRTIMP int __cdecl _open(const char *_Filename,int _Openflag,int _PermissionMode = 0); 583 extern "C++" _CRTIMP int __cdecl _sopen(const char *_Filename,int _Openflag,int _ShareFlag,int _PermissionMode = 0); 584 #endif 585 586 #ifndef _WIO_DEFINED 587 #define _WIO_DEFINED 588 589 _Check_return_ 590 _CRTIMP 591 int 592 __cdecl 593 _waccess( 594 _In_z_ const wchar_t *_Filename, 595 _In_ int _AccessMode); 596 597 _Check_return_ 598 _CRTIMP 599 int 600 __cdecl 601 _wchmod( 602 _In_z_ const wchar_t *_Filename, 603 _In_ int _Mode); 604 605 _Check_return_ 606 _CRTIMP 607 int 608 __cdecl 609 _wcreat( 610 _In_z_ const wchar_t *_Filename, 611 _In_ int _PermissionMode); 612 613 _Check_return_ 614 _CRTIMP 615 intptr_t 616 __cdecl 617 _wfindfirst32( 618 _In_z_ const wchar_t *_Filename, 619 _Out_ struct _wfinddata32_t *_FindData); 620 621 _Check_return_ 622 _CRTIMP 623 int 624 __cdecl 625 _wfindnext32( 626 _In_ intptr_t _FindHandle, 627 _Out_ struct _wfinddata32_t *_FindData); 628 629 _Check_return_ 630 _CRTIMP 631 int 632 __cdecl 633 _wunlink( 634 _In_z_ const wchar_t *_Filename); 635 636 _Check_return_ 637 _CRTIMP 638 int 639 __cdecl 640 _wrename( 641 _In_z_ const wchar_t *_NewFilename, 642 _In_z_ const wchar_t *_OldFilename); 643 644 _CRTIMP 645 wchar_t* 646 __cdecl 647 _wmktemp( 648 _Inout_z_ wchar_t *_TemplateName); 649 650 #if _INTEGRAL_MAX_BITS >= 64 651 652 _Check_return_ 653 _CRTIMP 654 intptr_t 655 __cdecl 656 _wfindfirst32i64( 657 _In_z_ const wchar_t *_Filename, 658 _Out_ struct _wfinddata32i64_t *_FindData); 659 660 _Check_return_ 661 _CRTIMP 662 intptr_t 663 __cdecl 664 _wfindfirst64i32( 665 _In_z_ const wchar_t *_Filename, 666 _Out_ struct _wfinddata64i32_t *_FindData); 667 668 _Check_return_ 669 _CRTIMP 670 intptr_t 671 __cdecl 672 _wfindfirst64( 673 _In_z_ const wchar_t *_Filename, 674 _Out_ struct _wfinddata64_t *_FindData); 675 676 _Check_return_ 677 _CRTIMP 678 int 679 __cdecl 680 _wfindnext32i64( 681 _In_ intptr_t _FindHandle, 682 _Out_ struct _wfinddata32i64_t *_FindData); 683 684 _Check_return_ 685 _CRTIMP 686 int 687 __cdecl 688 _wfindnext64i32( 689 _In_ intptr_t _FindHandle, 690 _Out_ struct _wfinddata64i32_t *_FindData); 691 692 _Check_return_ 693 _CRTIMP 694 int 695 __cdecl 696 _wfindnext64( 697 _In_ intptr_t _FindHandle, 698 _Out_ struct _wfinddata64_t *_FindData); 699 700 #endif /* _INTEGRAL_MAX_BITS >= 64 */ 701 702 _Check_return_wat_ 703 _CRTIMP 704 errno_t 705 __cdecl 706 _wsopen_s( 707 _Out_ int *_FileHandle, 708 _In_z_ const wchar_t *_Filename, 709 _In_ int _OpenFlag, 710 _In_ int _ShareFlag, 711 _In_ int _PermissionFlag); 712 713 #if !defined(__cplusplus) || !(defined(_X86_) && !defined(__x86_64)) 714 _CRTIMP int __cdecl _wopen(const wchar_t *_Filename,int _OpenFlag,...); 715 _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,...); 716 #else 717 extern "C++" _CRTIMP int __cdecl _wopen(const wchar_t *_Filename,int _OpenFlag,int _PermissionMode = 0); 718 extern "C++" _CRTIMP int __cdecl _wsopen(const wchar_t *_Filename,int _OpenFlag,int _ShareFlag,int _PermissionMode = 0); 719 #endif 720 721 #endif /* !_WIO_DEFINED */ 722 723 int 724 __cdecl 725 __lock_fhandle( 726 _In_ int _Filehandle); 727 728 void 729 __cdecl 730 _unlock_fhandle( 731 _In_ int _Filehandle); 732 733 _CRTIMP 734 intptr_t 735 __cdecl 736 _get_osfhandle( 737 _In_ int _FileHandle); 738 739 _CRTIMP 740 int 741 __cdecl 742 _open_osfhandle( 743 _In_ intptr_t _OSFileHandle, 744 _In_ int _Flags); 745 746 #ifndef NO_OLDNAMES 747 748 _Check_return_ 749 _CRTIMP 750 int 751 __cdecl 752 access( 753 _In_z_ const char *_Filename, 754 _In_ int _AccessMode); 755 756 _Check_return_ 757 _CRTIMP 758 int 759 __cdecl 760 chmod( 761 _In_z_ const char *_Filename, 762 _In_ int _AccessMode); 763 764 _Check_return_ 765 _CRTIMP 766 int 767 __cdecl 768 chsize( 769 _In_ int _FileHandle, 770 _In_ long _Size); 771 772 _Check_return_opt_ 773 _CRTIMP 774 int 775 __cdecl 776 close( 777 _In_ int _FileHandle); 778 779 _Check_return_ 780 _CRTIMP 781 int 782 __cdecl 783 creat( 784 _In_z_ const char *_Filename, 785 _In_ int _PermissionMode); 786 787 _Check_return_ 788 _CRTIMP 789 int 790 __cdecl 791 dup( 792 _In_ int _FileHandle); 793 794 _Check_return_ 795 _CRTIMP 796 int 797 __cdecl 798 dup2( 799 _In_ int _FileHandleSrc, 800 _In_ int _FileHandleDst); 801 802 _Check_return_ 803 _CRTIMP 804 int 805 __cdecl 806 __cdecl eof( 807 _In_ int _FileHandle); 808 809 _Check_return_ 810 _CRTIMP 811 long 812 __cdecl 813 filelength( 814 _In_ int _FileHandle); 815 816 _Check_return_ 817 _CRTIMP 818 int 819 __cdecl 820 isatty( 821 _In_ int _FileHandle); 822 823 _Check_return_ 824 _CRTIMP 825 int 826 __cdecl 827 locking( 828 _In_ int _FileHandle, 829 _In_ int _LockMode, 830 _In_ long _NumOfBytes); 831 832 _Check_return_opt_ 833 _CRTIMP 834 long 835 __cdecl 836 lseek( 837 _In_ int _FileHandle, 838 _In_ long _Offset, 839 _In_ int _Origin); 840 841 _CRTIMP 842 char* 843 __cdecl 844 mktemp( 845 _Inout_z_ char *_TemplateName); 846 847 _Check_return_ 848 _CRTIMP 849 int 850 __cdecl 851 open( 852 _In_z_ const char *_Filename, 853 _In_ int _OpenFlag, 854 ...); 855 856 _CRTIMP 857 int 858 __cdecl 859 read( 860 _In_ int _FileHandle, 861 _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, 862 _In_ unsigned int _MaxCharCount); 863 864 _Check_return_ 865 _CRTIMP 866 int 867 __cdecl 868 setmode( 869 _In_ int _FileHandle, 870 _In_ int _Mode); 871 872 _CRTIMP 873 int 874 __cdecl 875 sopen( 876 const char *_Filename, 877 int _OpenFlag, 878 int _ShareFlag, 879 ...); 880 881 _Check_return_ 882 _CRTIMP 883 long 884 __cdecl 885 tell( 886 _In_ int _FileHandle); 887 888 _CRTIMP 889 int 890 __cdecl 891 umask( 892 _In_ int _Mode); 893 894 _Check_return_ 895 _CRTIMP 896 int 897 __cdecl 898 write( 899 _In_ int _Filehandle, 900 _In_reads_bytes_(_MaxCharCount) const void *_Buf, 901 _In_ unsigned int _MaxCharCount); 902 903 #endif /* NO_OLDNAMES */ 904 905 #ifdef __cplusplus 906 } 907 #endif 908 #endif 909 910 #ifdef __cplusplus 911 extern "C" { 912 #endif 913 914 /* Misc stuff */ 915 char *getlogin(void); 916 #ifdef __USE_MINGW_ALARM 917 unsigned int alarm(unsigned int seconds); 918 #endif 919 920 #ifdef __USE_MINGW_ACCESS 921 /* Old versions of MSVCRT access() just ignored X_OK, while the version 922 shipped with Vista, returns an error code. This will restore the 923 old behaviour */ 924 static inline int __mingw_access (const char *__fname, int __mode) { 925 return _access (__fname, __mode & ~X_OK); 926 } 927 928 #define access(__f,__m) __mingw_access (__f, __m) 929 #endif 930 931 #ifdef __cplusplus 932 } 933 #endif 934 935 #pragma pack(pop) 936 937 #include <sec_api/io_s.h> 938 939 #endif /* End _IO_H_ */ 940 941