Skip to content
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

Improve input validation in read_PSL2R() #127

Closed
mcol opened this issue Aug 8, 2024 · 0 comments
Closed

Improve input validation in read_PSL2R() #127

mcol opened this issue Aug 8, 2024 · 0 comments

Comments

@mcol
Copy link
Contributor

mcol commented Aug 8, 2024

Function read_PSL2R() accepts either a single .psl file as input or a path to a directory where .psl files are searched. Note that we enter the second case also if a file with an extension other than .psl is given:

file <- list.files(file, pattern = ".psl$", full.names = TRUE, ignore.case = TRUE)
if (!all(file.exists(file)))
  stop(...)

If a directory path is given and if no .psl files are found, list.files() returns character(0), and in turn !all(file.exists(file)) is FALSE and the function doesn't stop!

The same failure occurs if the directory doesn't exist in the first place:

> read_PSL2R(file = system.file("extdata/non-existent-directory", package = "Luminescence"))
[read_PSL2R(): The following files were found and imported: 
 .. 
Error in file(con, "r") : invalid 'description' argument
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

No branches or pull requests

2 participants