io.files.info.unix.linux: Special characters in mount points are encoded as octal escape sequences.
parent
d23aa7e1f1
commit
67e7874e91
|
@ -0,0 +1,7 @@
|
||||||
|
! Copyright (C) 2015 Doug Coleman.
|
||||||
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
|
USING: tools.test io.files.info.unix.linux ;
|
||||||
|
IN: io.files.info.unix.linux.tests
|
||||||
|
|
||||||
|
[ "/media/erg/4TB D" ]
|
||||||
|
[ "/media/erg/4TB\\040D" decode-mount-point ] unit-test
|
|
@ -1,11 +1,9 @@
|
||||||
! Copyright (C) 2008 Doug Coleman.
|
! Copyright (C) 2008 Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors alien.c-types alien.syntax combinators csv
|
USING: accessors assocs classes.struct combinators csv
|
||||||
io.backend io.encodings.utf8 io.files io.files.info
|
io.backend io.encodings.utf8 io.files.info io.files.info.unix
|
||||||
io.files.unix libc libc.linux kernel math.order namespaces sequences
|
io.pathnames kernel libc math math.parser sequences splitting
|
||||||
sorting system unix unix.statfs.linux unix.statvfs.linux io.files.links
|
strings system unix.statfs.linux unix.statvfs.linux ;
|
||||||
arrays io.files.info.unix assocs io.pathnames unix.types
|
|
||||||
classes.struct ;
|
|
||||||
FROM: csv => delimiter ;
|
FROM: csv => delimiter ;
|
||||||
IN: io.files.info.unix.linux
|
IN: io.files.info.unix.linux
|
||||||
|
|
||||||
|
@ -44,11 +42,21 @@ M: linux statvfs>file-system-info ( file-system-info statfs -- file-system-info'
|
||||||
TUPLE: mtab-entry file-system-name mount-point type options
|
TUPLE: mtab-entry file-system-name mount-point type options
|
||||||
frequency pass-number ;
|
frequency pass-number ;
|
||||||
|
|
||||||
|
! octal escape sequences, e.g. "/media/erg/4TB\\040E"
|
||||||
|
: decode-mount-point ( string -- string' )
|
||||||
|
dup "\\" split
|
||||||
|
dup length 1 > [
|
||||||
|
nip 1 cut
|
||||||
|
[ 3 cut [ oct> 1string ] dip append ] map append concat
|
||||||
|
] [
|
||||||
|
drop
|
||||||
|
] if ;
|
||||||
|
|
||||||
: mtab-csv>mtab-entry ( csv -- mtab-entry )
|
: mtab-csv>mtab-entry ( csv -- mtab-entry )
|
||||||
[ mtab-entry new ] dip
|
[ mtab-entry new ] dip
|
||||||
{
|
{
|
||||||
[ first >>file-system-name ]
|
[ first >>file-system-name ]
|
||||||
[ second >>mount-point ]
|
[ second decode-mount-point >>mount-point ]
|
||||||
[ third >>type ]
|
[ third >>type ]
|
||||||
[ fourth string>csv first >>options ]
|
[ fourth string>csv first >>options ]
|
||||||
[ 4 swap ?nth [ 0 ] unless* >>frequency ]
|
[ 4 swap ?nth [ 0 ] unless* >>frequency ]
|
||||||
|
|
Loading…
Reference in New Issue