Skip to content
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
39 changes: 20 additions & 19 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
call = call
)
}
configure_unixodbc_simba(unixodbc_install[1], simba_config[1], action, call)
configure_unixodbc_simba(unixodbc_install, simba_config[1], action, call)

Check warning on line 352 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L352

Added line #L352 was not covered by tests
}

locate_install_unixodbc <- function() {
Expand All @@ -375,38 +375,39 @@
"/opt/R/x86_64/lib"
)

list.files(
common_dirs,
pattern = libodbcinst_filename(),
full.names = TRUE
)
return(libodbcinst_file(common_dirs))

Check warning on line 378 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L378

Added line #L378 was not covered by tests
}

system_safely <- function(x) {
tryCatch(
{
unixodbc_prefix <- system(x, intern = TRUE, ignore.stderr = TRUE)
candidates <- list.files(unixodbc_prefix,
pattern = libodbcinst_filename(), full.names = TRUE)
if (!length(candidates)) {
stop("Unable to locate unixodbc using odbc_config")
}
return(candidates[1])
return(libodbcinst_file(unixodbc_prefix))
},
error = function(e) {},
warning = function(w) {}
)
character()
}

# Returns a pattern to be used with
# list.files( ..., pattern = ... ).
libodbcinst_filename <- function() {
if (is_macos()) {
"libodbcinst.dylib|libodbcinst.a"
} else {
"libodbcinst.so|libodbcinst.a"
# Search for an instance of the unixodbc lib in
# the directories passed in the `dirs` argument.
# Preference is given to shared libraries.
libodbcinst_file <- function(dirs) {
if (is_windows()) {
return(character())

Check warning on line 398 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L398

Added line #L398 was not covered by tests
}
# Order matters, we prefer shlib (#919)
file_names <- ifelse(is_macos(), "libodbcinst.dylib", "libodbcinst.so")
file_names <- c(file_names, "libodbcinst.a")
for (file_name in file_names) {
candidates <- list.files(dirs,
pattern = file_name, full.names = TRUE)
if (length(candidates)) {
return(candidates[1])
}
}
return(character())

Check warning on line 410 in R/utils.R

View check run for this annotation

Codecov / codecov/patch

R/utils.R#L410

Added line #L410 was not covered by tests
}

error_install_unixodbc <- function(call) {
Expand Down
Loading