Skip to content

Commit

Permalink
Remove this.path.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbosak01 committed Jul 3, 2023
1 parent a71f3af commit 2fb3221
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 90 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ Suggests:
glue,
box
Enhances: base
Imports: this.path (< 2.0),
utils
Imports: utils
Config/testthat/edition: 3
RoxygenNote: 7.2.1
VignetteBuilder: knitr
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export("%eq%")
export("%p%")
export("labels<-")
export(Sys.path)
export(Sys.path.experimental)
export(copy.attributes)
export(dir.find)
export(file.find)
Expand Down
38 changes: 19 additions & 19 deletions R/file_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
# File Operations ---------------------------------------------------------


#' @title Returns the path of the current program
#' @description A function that gets the full path of the currently running
#' program. If the function fails to retrieve the path for some reason,
#' it will return a NULL. The function takes no parameters.
#' @returns The full path of the currently running program, or a NULL.
#' @family fileops
#' @examples
#' # Get current path
#' pth <- Sys.path()
#' pth
#' # [1] "C:/programs/myprogram.R"
#' @export
Sys.path <- function() {

ppth <- Sys.path.internal()

return(ppth)

}
# @title Returns the path of the current program
# @description A function that gets the full path of the currently running
# program. If the function fails to retrieve the path for some reason,
# it will return a NULL. The function takes no parameters.
# @returns The full path of the currently running program, or a NULL.
# @family fileops
# @examples
# # Get current path
# pth <- Sys.path()
# pth
# # [1] "C:/programs/myprogram.R"
# export
# Sys.path_back <- function() {
#
# ppth <- Sys.path.internal()
#
# return(ppth)
#
# }


# File Find ---------------------------------------------------------------
Expand Down
52 changes: 26 additions & 26 deletions R/syspath.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,42 @@



Sys.path.internal <- function() {

ppth <- NULL

tryCatch({

# if (utils::packageVersion("this.path") >= "2.0.0")
# ppth <- this.path::sys.path()
# else {
ppth <- this.path::this.path()

# }

}, error = function(e) { ppth <- NULL})


return(ppth)

}




#' @title EXPERIMENTAL: Returns the path of the current program
# Sys.path.internal <- function() {
#
# ppth <- NULL
#
# tryCatch({
#
# # if (utils::packageVersion("this.path") >= "2.0.0")
# # ppth <- this.path::sys.path()
# # else {
# ppth <- this.path::this.path()
#
# # }
#
# }, error = function(e) { ppth <- NULL})
#
#
# return(ppth)
#
# }




#' @title Returns the path of the current program
#' @description A function that gets the full path of the currently running
#' program. If the function fails to retrieve the path for some reason,
#' it will return a NULL. The function takes no parameters.
#' @returns The full path of the currently running program, or a NULL.
#' @family fileops
#' @examples
#' # Get current path
#' pth <- Sys.path.experimental()
#' pth <- Sys.path()
#' pth
#' # [1] "C:/programs/myprogram.R"
#' @export
Sys.path.experimental <- function() {
Sys.path <- function() {

ret <- NULL

Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ reference:
desc: Functions that help with file management.
contents:
- Sys.path
- Sys.path.experimental
- file.find
- dir.find

Expand Down
3 changes: 1 addition & 2 deletions man/Sys.path.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 0 additions & 29 deletions man/Sys.path.experimental.Rd

This file was deleted.

1 change: 0 additions & 1 deletion man/dir.find.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/file.find.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions tests/testthat/test-file_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ test_that("file8: Sys.path() works as expect.", {
})


test_that("file9: Sys.path.experimental() works as expect.", {


res <- Sys.path.experimental()

expect_equal(is.null(res), FALSE)

})
# test_that("file9: Sys.path.experimental() works as expect.", {
#
#
# res <- Sys.path.experimental()
#
# expect_equal(is.null(res), FALSE)
#
# })



Expand Down

0 comments on commit 2fb3221

Please sign in to comment.