io.directories.unix,environment.unix: better to use

native-string-encoding over hardcoding utf8
db4
Björn Lindqvist 2015-10-01 15:52:51 +02:00
parent bd04290187
commit dbcfc178ff
2 changed files with 8 additions and 9 deletions

View File

@ -1,9 +1,8 @@
! 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: alien alien.c-types alien.data alien.strings USING: alien.accessors alien.c-types alien.data alien.strings
alien.syntax kernel layouts libc sequences system unix alien.syntax environment io.encodings.utf8 kernel libc system unix.ffi
environment io.encodings.utf8 unix.utilities vocabs unix.utilities vocabs ;
combinators alien.accessors unix.ffi ;
IN: environment.unix IN: environment.unix
HOOK: environ os ( -- void* ) HOOK: environ os ( -- void* )
@ -22,7 +21,7 @@ M: unix set-os-env ( value key -- )
M: unix unset-os-env ( key -- ) unsetenv io-error ; M: unix unset-os-env ( key -- ) unsetenv io-error ;
M: unix (os-envs) ( -- seq ) M: unix (os-envs) ( -- seq )
environ void* deref utf8 alien>strings ; environ void* deref native-string-encoding alien>strings ;
: set-void* ( value alien -- ) 0 set-alien-cell ; : set-void* ( value alien -- ) 0 set-alien-cell ;

View File

@ -2,9 +2,9 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.data alien.strings assocs USING: accessors alien.c-types alien.data alien.strings assocs
classes.struct continuations fry io.backend io.backend.unix classes.struct continuations fry io.backend io.backend.unix
io.directories io.encodings.utf8 io.files io.files.info io.directories io.files io.files.info io.files.info.unix
io.files.info.unix io.files.types kernel libc literals math io.files.types kernel libc literals math sequences system unix
sequences system unix unix.ffi vocabs ; unix.ffi vocabs ;
IN: io.directories.unix IN: io.directories.unix
CONSTANT: touch-mode flags{ O_WRONLY O_APPEND O_CREAT O_EXCL } CONSTANT: touch-mode flags{ O_WRONLY O_APPEND O_CREAT O_EXCL }
@ -60,7 +60,7 @@ M: unix copy-file ( from to -- )
] 2keep void* deref ; inline ] 2keep void* deref ; inline
: >directory-entry ( dirent* -- directory-entry ) : >directory-entry ( dirent* -- directory-entry )
[ d_name>> utf8 alien>string ] [ d_name>> alien>native-string ]
[ d_type>> dirent-type>file-type ] bi [ d_type>> dirent-type>file-type ] bi
dup +unknown+ = [ drop dup file-info type>> ] when dup +unknown+ = [ drop dup file-info type>> ] when
<directory-entry> ; inline <directory-entry> ; inline