Skip to content

Foundation: remove a number of non-portable POSIX codes #2130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions Foundation/NSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,10 @@ extension POSIXError {
/// Bad address.
public static var EFAULT: POSIXError.Code { return .EFAULT }

#if !os(Windows)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was doing

#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Linux) || os(Android)
    /// Block device required.
    public static var ENOTBLK: POSIXError.Code { return .ENOTBLK }
    #endif

But yours is probably better xD

/// Block device required.
public static var ENOTBLK: POSIXError.Code { return .ENOTBLK }
#endif

/// Device / Resource busy.
public static var EBUSY: POSIXError.Code { return .EBUSY }
Expand Down Expand Up @@ -999,8 +1001,10 @@ extension POSIXError {
/// Inappropriate ioctl for device.
public static var ENOTTY: POSIXError.Code { return .ENOTTY }

#if !os(Windows)
/// Text file busy.
public static var ETXTBSY: POSIXError.Code { return .ETXTBSY }
#endif

/// File too large.
public static var EFBIG: POSIXError.Code { return .EFBIG }
Expand Down Expand Up @@ -1033,6 +1037,7 @@ extension POSIXError {
/// Resource temporarily unavailable.
public static var EAGAIN: POSIXError.Code { return .EAGAIN }

#if !os(Windows)
/// Operation would block.
public static var EWOULDBLOCK: POSIXError.Code { return .EWOULDBLOCK }

Expand All @@ -1041,9 +1046,11 @@ extension POSIXError {

/// Operation already in progress.
public static var EALREADY: POSIXError.Code { return .EALREADY }
#endif

/// IPC/Network software -- argument errors.

#if !os(Windows)
/// Socket operation on non-socket.
public static var ENOTSOCK: POSIXError.Code { return .ENOTSOCK }

Expand All @@ -1064,12 +1071,14 @@ extension POSIXError {

/// Socket type not supported.
public static var ESOCKTNOSUPPORT: POSIXError.Code { return .ESOCKTNOSUPPORT }
#endif

#if canImport(Darwin)
/// Operation not supported.
public static var ENOTSUP: POSIXError.Code { return .ENOTSUP }
#endif

#if !os(Windows)
/// Protocol family not supported.
public static var EPFNOSUPPORT: POSIXError.Code { return .EPFNOSUPPORT }

Expand All @@ -1081,9 +1090,11 @@ extension POSIXError {

/// Can't assign requested address.
public static var EADDRNOTAVAIL: POSIXError.Code { return .EADDRNOTAVAIL }
#endif

/// IPC/Network software -- operational errors

#if !os(Windows)
/// Network is down.
public static var ENETDOWN: POSIXError.Code { return .ENETDOWN }

Expand Down Expand Up @@ -1122,15 +1133,18 @@ extension POSIXError {

/// Too many levels of symbolic links.
public static var ELOOP: POSIXError.Code { return .ELOOP }
#endif

/// File name too long.
public static var ENAMETOOLONG: POSIXError.Code { return .ENAMETOOLONG }

#if !os(Windows)
/// Host is down.
public static var EHOSTDOWN: POSIXError.Code { return .EHOSTDOWN }

/// No route to host.
public static var EHOSTUNREACH: POSIXError.Code { return .EHOSTUNREACH }
#endif

/// Directory not empty.
public static var ENOTEMPTY: POSIXError.Code { return .ENOTEMPTY }
Expand All @@ -1142,19 +1156,23 @@ extension POSIXError {
public static var EPROCLIM: POSIXError.Code { return .EPROCLIM }
#endif

#if !os(Windows)
/// Too many users.
public static var EUSERS: POSIXError.Code { return .EUSERS }

/// Disk quota exceeded.
public static var EDQUOT: POSIXError.Code { return .EDQUOT }
#endif

/// Network File System

#if !os(Windows)
/// Stale NFS file handle.
public static var ESTALE: POSIXError.Code { return .ESTALE }

/// Too many levels of remote in path.
public static var EREMOTE: POSIXError.Code { return .EREMOTE }
#endif

#if canImport(Darwin)
/// RPC struct is bad.
Expand Down Expand Up @@ -1199,9 +1217,11 @@ extension POSIXError {
/// Device error, e.g. paper out.
public static var EDEVERR: POSIXError.Code { return .EDEVERR }
#endif


#if !os(Windows)
/// Value too large to be stored in data type.
public static var EOVERFLOW: POSIXError.Code { return .EOVERFLOW }
#endif

/// Program loading errors.

Expand All @@ -1220,7 +1240,8 @@ extension POSIXError {
/// Malformed Macho file.
public static var EBADMACHO: POSIXError.Code { return .EBADMACHO }
#endif


#if !os(Windows)
/// Operation canceled.
public static var ECANCELED: POSIXError.Code { return .ECANCELED }

Expand All @@ -1229,6 +1250,7 @@ extension POSIXError {

/// No message of desired type.
public static var ENOMSG: POSIXError.Code { return .ENOMSG }
#endif

/// Illegal byte sequence.
public static var EILSEQ: POSIXError.Code { return .EILSEQ }
Expand All @@ -1238,6 +1260,7 @@ extension POSIXError {
public static var ENOATTR: POSIXError.Code { return .ENOATTR }
#endif

#if !os(Windows)
/// Bad message.
public static var EBADMSG: POSIXError.Code { return .EBADMSG }

Expand All @@ -1261,17 +1284,20 @@ extension POSIXError {

/// STREAM ioctl timeout.
public static var ETIME: POSIXError.Code { return .ETIME }
#endif

#if canImport(Darwin)
/// No such policy registered.
public static var ENOPOLICY: POSIXError.Code { return .ENOPOLICY }
#endif

#if !os(Windows)
/// State not recoverable.
public static var ENOTRECOVERABLE: POSIXError.Code { return .ENOTRECOVERABLE }

/// Previous owner died.
public static var EOWNERDEAD: POSIXError.Code { return .EOWNERDEAD }
#endif

#if canImport(Darwin)
/// Interface output queue is full.
Expand Down