Skip to content

Commit fb29702

Browse files
authored
Merge pull request #24056 from colemancda/windowsPosixError
2 parents b29e8ba + 32fb498 commit fb29702

File tree

2 files changed

+127
-2
lines changed

2 files changed

+127
-2
lines changed

stdlib/public/Platform/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ add_swift_target_library(swiftGlibc ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_O
3939
add_swift_target_library(swiftMSVCRT ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY
4040
msvcrt.swift
4141
${swift_platform_sources}
42+
POSIXError.swift
4243

4344
GYB_SOURCES
4445
${swift_platform_gyb_sources}

stdlib/public/Platform/POSIXError.swift

Lines changed: 126 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
// FIXME: Only defining POSIXErrorCode for Darwin and Linux at the moment.
14-
1513
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
1614

1715
/// Enumeration describing POSIX error codes.
@@ -554,4 +552,130 @@ public enum POSIXErrorCode : Int32 {
554552
case ENOTRECOVERABLE = 131
555553
}
556554

555+
#elseif os(Windows)
556+
557+
/// Enumeration describing POSIX error codes.
558+
public enum POSIXErrorCode : Int32 {
559+
560+
/// Operation not permitted
561+
case EPERM = 1
562+
563+
/// No such file or directory
564+
case ENOENT = 2
565+
566+
/// No such process
567+
case ESRCH = 3
568+
569+
/// Interrupted function
570+
case EINTR = 4
571+
572+
/// I/O error
573+
case EIO = 5
574+
575+
/// No such device or address
576+
case ENXIO = 6
577+
578+
/// Argument list too long
579+
case E2BIG = 7
580+
581+
/// Exec format error
582+
case ENOEXEC = 8
583+
584+
/// Bad file number
585+
case EBADF = 9
586+
587+
/// No spawned processes
588+
case ECHILD = 10
589+
590+
/// No more processes or not enough memory or maximum nesting level reached
591+
case EAGAIN = 11
592+
593+
/// Not enough memory
594+
case ENOMEM = 12
595+
596+
/// Permission denied
597+
case EACCES = 13
598+
599+
/// Bad address
600+
case EFAULT = 14
601+
602+
/// Device or resource busy
603+
case EBUSY = 16
604+
605+
/// File exists
606+
case EEXIST = 17
607+
608+
/// Cross-device link
609+
case EXDEV = 18
610+
611+
/// No such device
612+
case ENODEV = 19
613+
614+
/// Not a directory
615+
case ENOTDIR = 20
616+
617+
/// Is a directory
618+
case EISDIR = 21
619+
620+
/// Invalid argument
621+
case EINVAL = 22
622+
623+
/// Too many files open in system
624+
case ENFILE = 23
625+
626+
/// Too many open files
627+
case EMFILE = 24
628+
629+
/// Inappropriate I/O control operation
630+
case ENOTTY = 25
631+
632+
/// File too large
633+
case EFBIG = 27
634+
635+
/// No space left on device
636+
case ENOSPC = 28
637+
638+
/// Invalid seek
639+
case ESPIPE = 29
640+
641+
/// Read-only file system
642+
case EROFS = 30
643+
644+
/// Too many links
645+
case EMLINK = 31
646+
647+
/// Broken pipe
648+
case EPIPE = 32
649+
650+
/// Math argument
651+
case EDOM = 33
652+
653+
/// Result too large
654+
case ERANGE = 34
655+
656+
/// Resource deadlock would occur
657+
case EDEADLK = 36
658+
659+
/// Same as EDEADLK for compatibility with older Microsoft C versions
660+
public static var EDEADLOCK: POSIXErrorCode { return .EDEADLK }
661+
662+
/// Filename too long
663+
case ENAMETOOLONG = 38
664+
665+
/// No locks available
666+
case ENOLCK = 39
667+
668+
/// Function not supported
669+
case ENOSYS = 40
670+
671+
/// Directory not empty
672+
case ENOTEMPTY = 41
673+
674+
/// Illegal byte sequence
675+
case EILSEQ = 42
676+
677+
/// String was truncated
678+
case STRUNCATE = 80
679+
}
680+
557681
#endif

0 commit comments

Comments
 (0)