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

replace parameter of save_workspace() corrected in R (not in Java) #47

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

* Correction of imports when the workspace contains no SAP.

* `replace` parameter of `save_workspace()` corrected in R (not in Java).

## [3.2.3] - 2024-07-12


Expand Down
9 changes: 8 additions & 1 deletion R/workspace.R
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
.jws_open <- function(file) {
if (missing(file) || is.null(file)) {
if (Sys.info()[["sysname"]] == "Windows") {
file <- utils::choose.files(

Check warning on line 155 in R/workspace.R

View workflow job for this annotation

GitHub Actions / lint

file=R/workspace.R,line=155,col=28,[namespace_linter] 'choose.files' is not exported from {utils}.
caption = "Select a workspace",
filters = c("JDemetra+ workspace (.xml)", "*.xml")
)
Expand Down Expand Up @@ -181,7 +181,7 @@
.jws_load <- function(file) {
if (missing(file) || is.null(file)) {
if (Sys.info()[["sysname"]] == "Windows") {
file <- utils::choose.files(

Check warning on line 184 in R/workspace.R

View workflow job for this annotation

GitHub Actions / lint

file=R/workspace.R,line=184,col=28,[namespace_linter] 'choose.files' is not exported from {utils}.
caption = "Select a workspace",
filters = c("JDemetra+ workspace (.xml)", "*.xml")
)
Expand Down Expand Up @@ -263,7 +263,14 @@
save_workspace <- function(jws, file, replace = FALSE) {
# version <- match.arg(tolower(version)[1], c("jd3", "jd2"))
version <- "jd3"
invisible(.jcall(jws, "Z", "saveAs", full_path(file), version, !replace))
file <- full_path(file)
if (replace && file.exists(file)) {
base::file.remove(file)
base::unlink(
gsub("\\.xml$", "", file),
recursive = TRUE)
}
invisible(.jcall(jws, "Z", "saveAs", file, version, !replace))
}

full_path <- function(path) {
Expand Down
Loading