You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2026/03/19 02:29:19 UTC
(spark-connect-swift) branch main updated: [SPARK-56070] Avoid `NSString.expandingTildeInPath` usage
This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-connect-swift.git
The following commit(s) were added to refs/heads/main by this push:
new 0b9ea49 [SPARK-56070] Avoid `NSString.expandingTildeInPath` usage
0b9ea49 is described below
commit 0b9ea497366521738ddebe15ea1bb9434dbac73a
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Wed Mar 18 19:29:13 2026 -0700
[SPARK-56070] Avoid `NSString.expandingTildeInPath` usage
### What changes were proposed in this pull request?
This PR replaces `NSString.expandingTildeInPath` with a pure Swift implementation using `FileManager.default.homeDirectoryForCurrentUser` in `SparkFileUtils`.
### Why are the changes needed?
`NSString.expandingTildeInPath` requires Objective-C Foundation bridging (`as NSString`), which is not available in `FoundationEssentials`. Replacing it with a pure Swift helper improves compatibility with `FoundationEssentials`.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the existing CI with the existing tests.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.6)
Closes #318 from dongjoon-hyun/SPARK-56070.
Authored-by: Dongjoon Hyun <do...@apache.org>
Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
Sources/SparkConnect/SparkFileUtils.swift | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/Sources/SparkConnect/SparkFileUtils.swift b/Sources/SparkConnect/SparkFileUtils.swift
index 9a74e46..74d3757 100644
--- a/Sources/SparkConnect/SparkFileUtils.swift
+++ b/Sources/SparkConnect/SparkFileUtils.swift
@@ -39,12 +39,24 @@ public enum SparkFileUtils {
if let fragment = url.fragment {
var components = URLComponents()
components.scheme = "file"
- components.path = (path as NSString).expandingTildeInPath
+ components.path = expandingTildeInPath(path)
components.fragment = fragment
return components.url?.absoluteURL
}
}
- return URL(fileURLWithPath: (path as NSString).expandingTildeInPath).absoluteURL
+ return URL(fileURLWithPath: expandingTildeInPath(path)).absoluteURL
+ }
+
+ private static func expandingTildeInPath(_ path: String) -> String {
+ guard path.hasPrefix("~") else { return path }
+ let homeDir = FileManager.default.homeDirectoryForCurrentUser.path
+ if path == "~" {
+ return homeDir
+ }
+ if path.hasPrefix("~/") {
+ return homeDir + path.dropFirst(1)
+ }
+ return path
}
/// Lists files recursively.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org