Skip to content

Commit f7376b1

Browse files
author
Peng Zhao
committed
update dir
1 parent c9cf63e commit f7376b1

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

DESCRIPTION

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: mindr
2-
Version: 1.2.1
3-
Date: 2019-02-28
2+
Version: 1.2.2
3+
Date: 2019-05-01
44
Title: Convert Files Between Markdown or Rmarkdown Files and Mindmaps
55
Author: Peng Zhao
66
Maintainer: Peng Zhao <[email protected]>

R/internal.R

+17-14
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,22 @@ dir4 <- function(path = getwd(),
254254
if (is.na(path))
255255
return(message('The path cannot be NA!'))
256256
if (dir.exists(path)) {
257-
# os <- Sys.info()['sysname']
258-
## windows ----
259-
# if(os == 'Windows') {
260-
# non_ascii <- readLines(system.file('resource/non-ascii-windows.txt', package = 'mindr'), encoding = 'UTF-8')
261-
# tree <- paste0('tree "', path, '"', ifelse(dir_files, ' /F', ''))
262-
# mytree <- system(tree, intern = T)
263-
# md <- mytree[-(1:3)]
264-
# ## dir_files
265-
# if(dir_files){
266-
# loc_files <- !(grepl(non_ascii[1], md) | grepl(non_ascii[3], md))
267-
# md[loc_files] <- unlist(sapply(md[loc_files], function(x) count_space(x, sep = non_ascii[2])))
268-
# }
269-
# } else {
257+
os <- Sys.info()['sysname']
258+
# windows ----
259+
if(os == 'Windows') {
260+
oldlocale <- Sys.getlocale('LC_CTYPE')
261+
on.exit(Sys.setlocale('LC_CTYPE', oldlocale))
262+
Sys.setlocale('LC_CTYPE', 'Chinese')
263+
non_ascii <- readLines(system.file('resource/non-ascii-windows.txt', package = 'mindr'), encoding = 'UTF-8')
264+
tree <- paste0('tree "', path, '"', ifelse(dir_files, ' /F', ''))
265+
mytree <- system(tree, intern = T, show.output.on.console = TRUE)
266+
md <- mytree[-(1:3)]
267+
## dir_files
268+
if(dir_files){
269+
loc_files <- !(grepl(non_ascii[1], md) | grepl(non_ascii[3], md))
270+
md[loc_files] <- unlist(sapply(md[loc_files], function(x) count_space(x, sep = non_ascii[2])))
271+
}
272+
} else {
270273
## non windows ----
271274
# data.tree method ----
272275
non_ascii <- readLines(system.file('resource/non-ascii-datatree.txt', package = 'mindr'), encoding = 'UTF-8')
@@ -279,7 +282,7 @@ dir4 <- function(path = getwd(),
279282
mytree <- data.tree::as.Node(data.frame(pathString = mydir))
280283
md <- print(mytree)[, 1]
281284
md[1] <- rootname
282-
# }
285+
}
283286

284287
# Both ----
285288
if ('txt' %in% output) {

0 commit comments

Comments
 (0)