library(tools)
# list all possible icons
images <- dir(
"~/RStudio/rstudio/src",
pattern = ".png",
full.names = TRUE,
recursive = TRUE)
# keep only the ones under paths we own
images <- images[grepl("cpp/desktop-mac/resources|gwt/src/org/rstudio/", images)]
# remove duplicates by hash
hashes <- md5sum(images)
# remove duplicate names for special treatmend
dupes <- images[duplicated(basename(images))]
icons <- images[!duplicated(basename(images))]
dupesRanamed <- lapply(seq_along(dupes), function(index) {
rename <- dupes[[index]]
basePath <- dirname(rename)
fileName <- basename(rename)
noExtension <- file_path_sans_ext(fileName)
extension <- file_ext(fileName)
renamed <- paste(noExtension, "-", index, ".", extension, sep = "")
file.path(basePath, renamed)
})
dupesNames <- basename(unlist(dupesRanamed))
The following are duplciates that need ot be mapped back:
as.data.frame(list(names = unlist(dupes), renames = dupesNames))
dupesFolder <- tempdir()
dupesPath <- file.path(dupesFolder, dupesNames)
copyRsult <- file.copy(dupes, dupesPath)
icons <- c(icons, dupesPath)
List of unique images:
as.data.frame(icons)
zip(zipfile = "icons.zip", files = icons, extras = c("-j"))