Skip to content

Fix currentWorkingDirectory #31

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kojirou1994
Copy link

String.init(cString:) may change the content

String.init(cString:) may change the content
@kojirou1994 kojirou1994 requested a review from iCharlesHu as a code owner April 25, 2025 06:34
Copy link
Contributor

@jakepetroules jakepetroules left a comment

Choose a reason for hiding this comment

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

Actually, this will break Windows because the platform string types won't match (UTF-16 != UTF-8). And Windows needs to use GetCurrentDirectoryW in order to support Unicode paths.

As an aside, according to POSIX, passing nil to getcwd is undefined behavior.

Essentially, we need to copy this: https://github.com/swiftlang/swift-foundation/blob/7002497ffceeeaf4916e06fd206724f1f801d2b5/Sources/FoundationEssentials/FileManager/FileManager%2BDirectories.swift#L494

@jakepetroules
Copy link
Contributor

@iCharlesHu Is there any reason not to use FileManager.default.currentDirectoryPath for this?

@iCharlesHu
Copy link
Contributor

@iCharlesHu Is there any reason not to use FileManager.default.currentDirectoryPath for this?

This package can't hard depend on Foundation because it's optional via a trait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants