[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/01: installer: Factor out scandir-with-slashes.
From: |
Danny Milosavljevic |
Subject: |
01/01: installer: Factor out scandir-with-slashes. |
Date: |
Wed, 5 Jul 2017 07:03:58 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 6895b6748ee58a34f763ddba23cc99362f6ab438
Author: Danny Milosavljevic <address@hidden>
Date: Wed Jul 5 13:01:49 2017 +0200
installer: Factor out scandir-with-slashes.
* gnu/system/installer/utils.scm (scandir-with-slashes): New variable.
Export it.
* gnu/system/installer/key-map.scm (key-map-page-init): Use it here.
* gnu/system/installer/time-zone.scm (time-zone-page-init): Use it here.
---
gnu/system/installer/key-map.scm | 11 +++--------
gnu/system/installer/time-zone.scm | 14 ++++----------
gnu/system/installer/utils.scm | 10 ++++++++++
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/gnu/system/installer/key-map.scm b/gnu/system/installer/key-map.scm
index 1269de0..c460165 100644
--- a/gnu/system/installer/key-map.scm
+++ b/gnu/system/installer/key-map.scm
@@ -25,7 +25,6 @@
#:use-module (gurses buttons)
#:use-module (ncurses curses)
#:use-module (ice-9 match)
- #:use-module (ice-9 ftw)
#:export (make-key-map))
@@ -98,13 +97,9 @@
(menu (make-menu
(let ((dir (page-datum p 'directory)))
- (map (lambda (name)
- (match (stat:type (stat (string-append dir "/" name)))
- ('directory (string-append name "/"))
- (_ name)))
- (filter (lambda (name)
- (not (string=? name ".")))
- (scandir dir)))))))
+ (filter (lambda (name)
+ (not (string=? name ".")))
+ (scandir-with-slashes dir))))))
(menu-post menu menu-window)
diff --git a/gnu/system/installer/time-zone.scm
b/gnu/system/installer/time-zone.scm
index 3f2f622..00bda6e 100644
--- a/gnu/system/installer/time-zone.scm
+++ b/gnu/system/installer/time-zone.scm
@@ -24,7 +24,6 @@
#:use-module (gurses menu)
#:use-module (gurses buttons)
#:use-module (ncurses curses)
- #:use-module (ice-9 ftw)
#:use-module (ice-9 match)
#:export (make-tz-browser))
@@ -104,18 +103,13 @@
(menu (make-menu
(let* ((dir (page-datum p 'directory))
- (all-names (scandir dir))
+ (all-names (scandir-with-slashes dir))
(useful-names (filter (lambda (name)
(and
- (not (string=? "." name))
+ (not (string=? "./" name))
(not (string-suffix? ".tab"
name))))
- all-names))
- (marked-useful-names (map (lambda (name)
- (match (stat:type (stat
(string-append dir "/" name)))
- ('directory (string-append
name "/"))
- (_ name)))
- useful-names)))
- (sort marked-useful-names string<)))))
+ all-names)))
+ (sort useful-names string<)))))
(menu-post menu menu-window)
diff --git a/gnu/system/installer/utils.scm b/gnu/system/installer/utils.scm
index a021eb3..d8475b0 100644
--- a/gnu/system/installer/utils.scm
+++ b/gnu/system/installer/utils.scm
@@ -41,10 +41,13 @@
window-pipe
pipe-cmd
refresh*
+
+ scandir-with-slashes
select-key?))
(use-modules (ice-9 popen)
+ (ice-9 ftw)
(ice-9 rdelim)
(ice-9 match)
(ncurses menu)
@@ -316,3 +319,10 @@ mounts return the device on which the path IN would be
mounted."
(list-head subject len)))
(caar pp)
(loop (cdr pp))))))))
+
+(define (scandir-with-slashes dir)
+ (map (lambda (name)
+ (match (stat:type (stat (string-append dir "/" name)))
+ ('directory (string-append name "/"))
+ (_ name)))
+ (scandir dir)))