Skip to content

Commit

Permalink
file_path_checking add NULL valid value file_path
Browse files Browse the repository at this point in the history
Add NULL as valid value for file_path #7 third comment
  • Loading branch information
OceaneBouhineauIRD committed Jul 12, 2024
1 parent 00e86b2 commit e7026cb
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions R/file_path_checking.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,38 @@ file_path_checking <- function(file_path,
"logical"),
output = "message"))
}
file_path_extension <- dplyr::last(x = unlist(x = strsplit(
x = file_path,
split = "[.]"
)))
if (! file_path_extension %in% extension) {
message_failure <- paste0(format(x = Sys.time(),
"%Y-%m-%d %H:%M:%S"),
" - Failure,",
" invalid \"extension\" argument.\n",
"File extension expected should be ", paste0("\"", extension, collapse = "\", "), "\" (extension provides is \"", file_path_extension, "\").\n")
if (output == "message") {
return(cat(message_failure))
} else if (output == "error") {
return(stop(message_failure))
} else if (output == "logical") {
return(FALSE)
if (!is.null(file_path)) {
file_path_extension <- dplyr::last(x = unlist(x = strsplit(
x = file_path,
split = "[.]"
)))
if (!file_path_extension %in% extension) {
message_failure <- paste0(format(x = Sys.time(),
"%Y-%m-%d %H:%M:%S"),
" - Failure,",
" invalid \"extension\" argument.\n",
"File extension expected should be ", paste0("\"", extension, collapse = "\", "), "\" (extension provides is \"", file_path_extension, "\").\n")
if (output == "message") {
return(cat(message_failure))
} else if (output == "error") {
return(stop(message_failure))
} else if (output == "logical") {
return(FALSE)
}
}
}
if (! file.exists(file_path)) {
message_failure <- paste0(format(x = Sys.time(),
"%Y-%m-%d %H:%M:%S"),
" - Failure,",
" invalid \"file_path\" argument.\n",
"No file located at the file path.\n")
if (output == "message") {
return(cat(message_failure))
} else if (output == "error") {
return(stop(message_failure))
} else if (output == "logical") {
return(FALSE)
if (!file.exists(file_path)) {
message_failure <- paste0(format(x = Sys.time(),
"%Y-%m-%d %H:%M:%S"),
" - Failure,",
" invalid \"file_path\" argument.\n",
"No file located at the file path.\n")
if (output == "message") {
return(cat(message_failure))
} else if (output == "error") {
return(stop(message_failure))
} else if (output == "logical") {
return(FALSE)
}
}
}
if (output == "message") {
Expand Down

0 comments on commit e7026cb

Please sign in to comment.