Browse Source

Package Title/Description change + URL reading for read_dsstore()

master
boB Rudis 6 years ago
parent
commit
f4f1c313a3
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 6
      DESCRIPTION
  2. 3
      R/mactheknife-package.R
  3. 35
      R/read-dsstore.R
  4. 3
      R/utils.R
  5. 17
      README.Rmd
  6. 22
      README.md
  7. 3
      man/mactheknife.Rd
  8. 12
      man/read_dsstore.Rd

6
DESCRIPTION

@ -1,6 +1,6 @@
Package: mactheknife
Type: Package
Title: Read 'macOS' .DS_Store' Files
Title: Various 'macOS'-oriented Tools and Utilities
Version: 0.1.0
Date: 2018-04-29
Authors@R: c(
@ -10,8 +10,8 @@ Authors@R: c(
comment = "Python dsstore module <https://github.com/gehaxelt/Python-dsstore>")
)
Maintainer: Bob Rudis <bob@rud.is>
Description: A thin wrapper around the 'Python' 'dsstore' module
<https://github.com/gehaxelt/Python-dsstore> by 'Sebastian Neef'.
Description: A set of tools/methods and data that are geared towards the 'macOS'
ecosystem.
URL: https://github.com/hrbrmstr/mactheknife
BugReports: https://github.com/hrbrmstr/mactheknife/issues
SystemRequirements: Python

3
R/mactheknife-package.R

@ -1,7 +1,6 @@
#' Read 'macOS' .DS_Store' Files
#'
#' A thin wrapper around the 'Python' 'dsstore' module
#' <https://github.com/gehaxelt/Python-dsstore> by 'Sebastian Neef'.
#' A set of tools/methods and data that are geared towards the 'macOS' ecosystem.
#'
#' @md
#' @name mactheknife

35
R/read-dsstore.R

@ -1,22 +1,49 @@
#' Read a `.DS_Store` file
#' Read a `.DS_Store` from a file/URL
#'
#' @md
#' @param path a path to a valid `.DS_Store` file ([path.expand()] will be called)
#' @param path a path to a valid `.DS_Store` file ([path.expand()] will be called) _or_
#' a link to an `http[s]` reachable `.DS_Store` file. If a URL, [download.file()]
#' will be used to retrieve the remote `.DS_Store` file (to reduce package
#' dependencies).
#' @return a character vector of filenames in the `.DS_Store` file or
#' a length 0 character vector if no parseable data was found
#' @export
#' @references A thin wrapper around the 'Python' 'dsstore' module <https://github.com/gehaxelt/Python-dsstore> by 'Sebastian Neef'.
#' @examples
#' read_dsstore(system.file("extdat", "DS_Store.ctf", package = "mactheknife"))
read_dsstore <- function(path) {
path_is_url <- FALSE
if (is_url(path)) {
path_is_url <- TRUE
remote_path <- path
path <- tempfile(fileext = ".dsstore.tmp")
on.exit(unlink(path))
ret <- download.file(remote_path, path, quiet = TRUE, mode = "wb")
if (ret != 0) {
warning(".DS_Store file not found at the provided URL.")
return(character())
}
}
stor_path <- path.expand(path)
stor_path <- normalizePath(stor_path)
if ((!path_is_url) & (!file.exists(stor_path))) {
warning(".DS_Store file not found at specified path.")
return(character())
}
fil <- os$open(stor_path, os$O_RDONLY)
contents <- os$read(fil, as.integer(file.size(stor_path)))
os$close(fil)
d <- dsstore$DS_Store(contents)
d <- try(dsstore$DS_Store(contents), silent = TRUE)
if (inherits(d, "try-error")) {
warning("Not a valid .DS_Store file.")
return(character())
}
ds_fils <- d$traverse_root()
@ -24,6 +51,6 @@ read_dsstore <- function(path) {
if (length(out) == 0) out <- character()
out
return(out)
}

3
R/utils.R

@ -0,0 +1,3 @@
is_url <- function(path) {
grepl("^(http|ftp)s?://", path)
}

17
README.Rmd

@ -4,20 +4,19 @@ output: rmarkdown::github_document
# mactheknife
Read 'macOS' .DS_Store' Files
Various 'macOS'-oriented Tools and Utilities
## Description
A thin wrapper around the 'Python' 'dsstore' module <https://github.com/gehaxelt/Python-dsstore> by 'Sebastian Neef'.
A set of tools/methods and data that are geared towards the 'macOS' ecosystem.
## NOTE
- This may turn into a broader "macOS hacking" package
- Uses `reticulate` so a working Python implementation is needed
## What's Inside The Tin
- `read_dsstore`: Read a '.DS_Store' file
- `read_dsstore`: Read a '.DS_Store' from a file/URL
The following functions are implemented:
@ -41,7 +40,7 @@ packageVersion("mactheknife")
```
## Built-in data
## `.DS_Store` example using built-in data
```{r}
read_dsstore(
@ -49,7 +48,13 @@ read_dsstore(
)
```
## My "~/projects" folder (use your own dir as an example)
## A URL I should not have let a `.DS_Store` file lying around in
```{r}
read_dsstore("https://rud.is/books/21-recipes/.DS_Store")
```
## `.DS_Store` larger example using my "~/projects" folder (use your own dir as an example)
```{r}
library(magrittr)

22
README.md

@ -1,21 +1,20 @@
# mactheknife
Read ‘macOS’ .DS\_Store’ Files
Various ‘macOS’-oriented Tools and Utilities
## Description
A thin wrapper around the ‘Python’ ‘dsstore’ module
<https://github.com/gehaxelt/Python-dsstore> by ‘Sebastian Neef’.
A set of tools/methods and data that are geared towards the ‘macOS’
ecosystem.
## NOTE
- This may turn into a broader “macOS hacking” package
- Uses `reticulate` so a working Python implementation is needed
## What’s Inside The Tin
- `read_dsstore`: Read a ‘.DS\_Store’ file
- `read_dsstore`: Read a ‘.DS\_Store’ from a file/URL
The following functions are implemented:
@ -36,7 +35,7 @@ packageVersion("mactheknife")
## [1] '0.1.0'
## Built-in data
## `.DS_Store` example using built-in data
``` r
read_dsstore(
@ -46,7 +45,16 @@ read_dsstore(
## [1] "favicon.ico" "flag" "static" "templates" "vulnerable.py" "vulnerable.wsgi"
## My “~/projects” folder (use your own dir as an example)
## A URL I should not have let a `.DS_Store` file lying around in
``` r
read_dsstore("https://rud.is/books/21-recipes/.DS_Store")
```
## [1] "06-Creating-a-Graph-of-Retweet-Relationships_files" "07-Visualizing-a-Graph-of-Retweet-Relationships_files"
## [3] "20-Visualizing-Geodata-with-a-Dorling-Cartogram_files" "libs"
## `.DS_Store` larger example using my “~/projects” folder (use your own dir as an example)
``` r
library(magrittr)

3
man/mactheknife.Rd

@ -6,8 +6,7 @@
\alias{mactheknife-package}
\title{Read 'macOS' .DS_Store' Files}
\description{
A thin wrapper around the 'Python' 'dsstore' module
\url{https://github.com/gehaxelt/Python-dsstore} by 'Sebastian Neef'.
A set of tools/methods and data that are geared towards the 'macOS' ecosystem.
}
\author{
Bob Rudis (bob@rud.is)

12
man/read_dsstore.Rd

@ -2,20 +2,26 @@
% Please edit documentation in R/read-dsstore.R
\name{read_dsstore}
\alias{read_dsstore}
\title{Read a \code{.DS_Store} file}
\title{Read a \code{.DS_Store} from a file/URL}
\usage{
read_dsstore(path)
}
\arguments{
\item{path}{a path to a valid \code{.DS_Store} file (\code{\link[=path.expand]{path.expand()}} will be called)}
\item{path}{a path to a valid \code{.DS_Store} file (\code{\link[=path.expand]{path.expand()}} will be called) \emph{or}
a link to an \code{http[s]} reachable \code{.DS_Store} file. If a URL, \code{\link[=download.file]{download.file()}}
will be used to retrieve the remote \code{.DS_Store} file (to reduce package
dependencies).}
}
\value{
a character vector of filenames in the \code{.DS_Store} file or
a length 0 character vector if no parseable data was found
}
\description{
Read a \code{.DS_Store} file
Read a \code{.DS_Store} from a file/URL
}
\examples{
read_dsstore(system.file("extdat", "DS_Store.ctf", package = "mactheknife"))
}
\references{
A thin wrapper around the 'Python' 'dsstore' module \url{https://github.com/gehaxelt/Python-dsstore} by 'Sebastian Neef'.
}

Loading…
Cancel
Save