diff --git a/NAMESPACE b/NAMESPACE index 83d3fd2..f20a3c6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,6 +7,7 @@ export(kernel_state) export(logger) export(read_dsstore) export(read_plist) +export(resolve_alias) export(software_update_history) export(sw_vers) export(system_profile) diff --git a/R/RcppExports.R b/R/RcppExports.R new file mode 100644 index 0000000..b215f22 --- /dev/null +++ b/R/RcppExports.R @@ -0,0 +1,8 @@ +# Generated by using Rcpp::compileAttributes() -> do not edit by hand +# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 + +#' @export +resolve_alias <- function(path) { + .Call('_mactheknife_resolve_alias', PACKAGE = 'mactheknife', path) +} + diff --git a/R/resolve-alias.R b/R/resolve-alias.R new file mode 100644 index 0000000..1578838 --- /dev/null +++ b/R/resolve-alias.R @@ -0,0 +1,22 @@ +#' Resolve macOS Alias Files to POSIX path strings +#' +#' @md +#' @param path path to the target alias +#' @return character vector +#' @export +resolve_alias <- function(path) { + + if (file.exists(path[1])) { + (applescript(sprintf(' +set myPosix to POSIX file "%s" +tell application "Finder" + set myPath to original item of item myPosix +end tell +set myPOSIXPath to POSIX path of (myPath as text) +return myPOSIXPath +', path.expand(path[1])))) + } else { + NULL + } + +} \ No newline at end of file diff --git a/README.Rmd b/README.Rmd index e526101..c88849e 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,6 +20,7 @@ The following functions are implemented: - `airport_scan`: Scan for available wireless network (requires Wi-Fi enabled Mac) - `applescript`: Execute AppleScript and Return Results +- `resolve_alias`: Resovle macOS binary alias files to their POSIX path strings - `kernel_state`: Retrieve kernel state information - `find_dsstore`: Find and optionally remove '.DS_Store' files on a locally-accessible filesystem - `read_dsstore`: Read a '.DS_Store' from a file/URL diff --git a/README.md b/README.md index a9d5372..50a0d50 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ The following functions are implemented: - `airport_scan`: Scan for available wireless network (requires Wi-Fi enabled Mac) - `applescript`: Execute AppleScript and Return Results + - `resolve_alias`: Resovle macOS binary alias files to their POSIX path strings - `kernel_state`: Retrieve kernel state information - `find_dsstore`: Find and optionally remove ‘.DS\_Store’ files on a locally-accessible filesystem diff --git a/inst/modules/__pycache__/dsstore.cpython-37.pyc b/inst/modules/__pycache__/dsstore.cpython-37.pyc index ff905ab..379ca0f 100644 Binary files a/inst/modules/__pycache__/dsstore.cpython-37.pyc and b/inst/modules/__pycache__/dsstore.cpython-37.pyc differ diff --git a/man/resolve_alias.Rd b/man/resolve_alias.Rd new file mode 100644 index 0000000..668267d --- /dev/null +++ b/man/resolve_alias.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/resolve-alias.R +\name{resolve_alias} +\alias{resolve_alias} +\title{Resolve macOS Alias Files to POSIX path strings} +\usage{ +resolve_alias(path) +} +\arguments{ +\item{path}{path to the target alias} +} +\value{ +character vector +} +\description{ +Resolve macOS Alias Files to POSIX path strings +}