|
1 | 1 | #' @importFrom rlang abort |
2 | 2 | NULL |
3 | 3 |
|
4 | | -#' Check if a path is a local filesystem path (not a cloud URI) |
5 | | -#' |
6 | | -#' @param path Character. Path to check. |
7 | | -#' @return Logical. TRUE if the path is a local filesystem path. |
8 | | -#' @noRd |
9 | | -is_local_path <- function(path) { |
10 | | - # Cloud storage URIs typically start with a scheme like s3://, gs://, az://, abfs://, etc. |
11 | | - |
12 | | - !grepl("^[a-zA-Z][a-zA-Z0-9+.-]*://", path) |
13 | | -} |
14 | 4 |
|
15 | 5 | #' Ensure directory exists for local paths |
16 | 6 | #' |
@@ -120,6 +110,15 @@ write_deltalake <- function( |
120 | 110 | stop("'table_or_uri' must be a single character string") |
121 | 111 | } |
122 | 112 |
|
| 113 | + # Normalize path if it's a local path to avoid mixed slashes on Windows |
| 114 | + if (is_local_path(table_or_uri)) { |
| 115 | + table_or_uri <- normalizePath( |
| 116 | + table_or_uri, |
| 117 | + mustWork = FALSE, |
| 118 | + winslash = "/" |
| 119 | + ) |
| 120 | + } |
| 121 | + |
123 | 122 | # Create directory if it's a local path and doesn't exist |
124 | 123 | ensure_directory_exists(table_or_uri) |
125 | 124 |
|
@@ -227,6 +226,11 @@ create_deltalake <- function( |
227 | 226 | stop("'table_uri' must be a single character string") |
228 | 227 | } |
229 | 228 |
|
| 229 | + # Normalize path if it's a local path to avoid mixed slashes on Windows |
| 230 | + if (is_local_path(table_uri)) { |
| 231 | + table_uri <- normalizePath(table_uri, mustWork = FALSE, winslash = "/") |
| 232 | + } |
| 233 | + |
230 | 234 | # Create directory if it's a local path and doesn't exist |
231 | 235 | ensure_directory_exists(table_uri) |
232 | 236 |
|
|
0 commit comments