47 Commits
Author SHA1 Message Date
YR Chen 58a2725013 Fix building on Windows 2021-08-05 10:05:06 -06:00
Rauhul Varma e520e61616 Fix SystemChar isLetter logic
- Fixes range expression in isLetter logic and adds test coverage.
2021-08-05 10:03:53 -06:00
Rauhul Varma 4f36710d0b Expose O_DIRECTORY as api
- Adds a `directory` OpenOptions as a type-safe version of O_DIRECTORY.
  Allows clients to only open a FileDescriptor for FilePaths that refer
  to directories.
2021-07-14 18:24:52 -06:00
Alex Martini 591ff41944 Move TODO and FIXME markers to normal comments.
When they appear in triple-slash comments, that makes them part of the
actual documentation that gets published.

Fixes <rdar://problem/79071171>.
2021-06-10 16:34:32 -06:00
Michael Ilseman 2bc160bfe3 FilePath.Component.Kind is meant to be frozen 2021-05-13 15:42:38 -06:00
Michael Ilseman 578586ab80 Un-deprecate withCString
Un-deprecate withCString, but make sure it's not available on Windows (because
the types will not match). withPlatformString is still the preferred
expression of this and favors more portable code.
2021-05-10 13:32:31 -06:00
Michael Ilseman 090d109c0f Make retryOnInterrupt always explicit internally 2021-03-22 15:58:10 -06:00
Saleem Abdulrasool 603718e247 FilePath: enable building on Windows (#41)
When building on Windows, we rely on the `withPlatformString` to convert
the strings to the native platform encoding (UTF-16).  The public
`FilePath.withPlatformString` is marked as `@_alwaysEmitIntoClient` and
references the `_withPlatformString` which is marked as `internal`.
Annotate the function as `@usableFromInline` to enable the inlined
method to reference this function.
2021-03-20 17:29:54 -06:00
Saleem Abdulrasool 65a906baf1 Internals: replace CModeT with CInterop.Mode (#40)
The typealias was renamed but the reference to it was not fully removed.
This updates the instance enabling building System on Windows.
2021-03-20 12:32:13 -06:00
Michael Ilseman a973b97147 [docs] Fixup code example (#39) 2021-03-18 16:18:39 -06:00
Saleem Abdulrasool b614185c90 build: add a CMake based build system (#38)
This will allow using Swift System in the toolchain stack, allowing us
to bootstrap a toolchain.
2021-03-18 16:18:24 -06:00
Saleem Abdulrasool dd1da2991e Internals: add Windows error code equivalences (#37)
Windows does not have the same set of error codes as a POSIX system.
However, the WinSock subsystem provides a set of error codes which are
meant to provide a means for handling similar error scenarios with
sockets.  This additionally adds an additional error code which allows
us to add back a previously ignored error code.
2021-03-16 19:25:12 -06:00
Saleem Abdulrasool bdfeb29148 Internals: adjust the definition of CInterop.Mode for Windows (#36)
Windows does not have a `mode_t` type, instead it uses `int` as a
stand in.  Adjust the type alias to reflect this.
2021-03-16 19:24:59 -06:00
Saleem Abdulrasool 83875613ec Internals: use CInterop.PlatformUnicodeString on Windows (#34)
The typealias was renamed but the Windows side of the build was not
updated.  This prevents building System on Windows.
2021-03-16 19:24:10 -06:00
Michael Ilseman 58e9e1c0c9 Ugly, ugly workaround for Swift 5.3.3 bug 2021-03-15 17:43:14 -06:00
Michael Ilseman cd4b42e03d Mocking helper for path strings 2021-03-15 15:18:54 -06:00
Michael Ilseman 8031239cef Emit withPlatformString as an availability workaround for open 2021-03-15 15:18:51 -06:00
Michael Ilseman 8b989f724f Do not import CSystem on Darwin 2021-02-27 10:59:54 -07:00
Michael Ilseman b28263a910 Fixup some merge issues 2021-02-26 12:59:31 -07:00
Michael Ilseman bae68a5651 Use C type in typealias 2021-02-25 21:49:27 -07:00
Michael Ilseman b6558a3a90 Normal imports
System is not an overlay and will not pull C and platform modules into the
user's namespace. Import constants normally rather than redefining them.
2021-02-25 21:40:25 -07:00
Karoy Lorentey b9d290dc1e Add missing @_implementationOnly attribute 2021-02-25 21:14:46 -07:00
Michael Ilseman 0734450867 Fixup compilation failures for some compilers 2021-02-25 21:14:46 -07:00
Michael Ilseman d7611ca8ad Internalize SystemInternals
Scrap the separate module SystemInternals and instead have it be a
subdirectory. Adjust all access control accordingly. One day, when Swift gets
proper submodules or supermodules (i.e. resilience domains), we can reinstate
it. For now, a separate module makes binary distribution much more
complicated.
2021-02-25 21:14:46 -07:00
Michael Ilseman b63554656d [gardening] Privatization of Mocking 2021-02-25 21:14:44 -07:00
Michael Ilseman 7b33caf850 Add commented out availability.
Add it for public APIs, though we will likely have to add it for internal
stuff too as a compiler workaround.
2021-02-25 21:11:15 -07:00
Karoy Lorentey 2d24a58a41 Add support for dup/dup2 2021-02-24 13:30:07 -08:00
Michael Ilseman 03c0b7ada5 Fix release builds by making assert into fatalError 2021-02-08 09:21:35 -07:00
Karoy Lorentey 2904f9ead3 Add symbolic names for standard file descriptors 2021-02-05 19:35:18 -08:00
Michael IlsemanandKyle Macomber d24083e1be Integrate API review
Fix bug in _modify and add better testing. Change lexicallyNormal to
lexicallyNormalized() to match "ed" rule.

Fix up some comments and remove some dead code

Co-authored-by: Kyle Macomber <kmacomber@apple.com>
2021-02-04 16:34:20 -07:00
Michael Ilseman 05e3d04b0c Drop Component.isSpecialDirectory
This API is fully redundant with .kind == .regular and could be a source of
confusion and namespace pollution. Drop it for now, and we can add something
equivalent in the future when we have more component-analysis APIs.
2021-02-02 07:49:42 -07:00
Michael Ilseman 2167575e66 Add FilePath Syntactic Operations API
Add the proposed non-file-system-interacting FilePath operations, Component,
Root, and ComponentView.

Proposal: https://forums.swift.org/t/api-review-filepath-syntactic-apis-version-2/44197

This change includes API/ABI additions and deprecations.
2021-02-01 08:42:44 -07:00
Michael Ilseman 920ef3085d Add PlatformString and Windows support
Add CInterop namespace and PlatformChar/PlatformEncoding typealiases for
narrow/wide characters.

Change Windows syscalls to use wide-character variants. Add full Windows root
parser to error-correct malformed roots and correctly normalize roots and
post-root portions of the path.

Add platformString APIs as replacements for cString APIs.

Add internal SystemString as backing storage type for FilePath.

Add Windows path mocking support.

This change includes API/ABI additions and deprecations.
2021-02-01 08:20:05 -07:00
Michael Ilseman 79eed1f99d Enforce at construction/mutation that FilePath's separators are normalized 2020-11-13 17:28:05 -08:00
Michael Ilseman 5d1b2fb985 Folders for FilePath and Platform sources 2020-11-13 16:57:25 -08:00
Saleem Abdulrasool 4ffcc62e9b Initial port to Windows
This adds enough shims and tweaks the types sufficiently to allow
building System on Windows.
2020-11-03 15:03:51 -08:00
Saleem Abdulrasool ac6ec0b19d SystemInternals: make WindowsSyscallAdapters build
Correct some type errors, missing return type.  Add a FIXME comment
regarding large file access.
2020-10-24 12:16:33 -07:00
Saleem Abdulrasool bf90fedc88 SystemInternals: make Mocking build on Windows
Fix some of the type errors and add missing imports.
2020-10-23 14:32:24 -07:00
Michael Ilseman 1eeeaf7200 Initial Windows syscall adapters 2020-10-23 09:07:41 -07:00
Michael Ilseman 5712a28377 Windows TLS mocking support 2020-10-23 09:07:41 -07:00
Michael Ilseman 173c684973 TLS helpers to ease Windows support 2020-10-22 14:42:03 -07:00
Michael Ilseman d2e26f72f3 Fix memory leak in withMockingEnabled 2020-10-22 10:43:12 -07:00
Michael Ilseman a8d07f8a04 Leverage conditional compilation to reduce mocking boilerplate 2020-10-22 10:39:09 -07:00
Michael Ilseman 98a1531ea0 Remove mocking infrastructure from non-mocking builds 2020-10-21 16:09:04 -07:00
Michael Ilseman 138c7f1a71 Add Linux support for syscall mocking 2020-10-21 09:40:08 -07:00
Michael Ilseman 9489545fed Syscall mock testing
Adds mocking and tracing infrastructure, test
infrastructure, and trace-based tests.
2020-10-21 09:22:46 -07:00
Michael Ilseman 8ffa04c0a0 Initial version of Swift System 2020-09-25 08:20:58 -07:00