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.
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types alien.data alien.strings
alien.syntax kernel layouts libc sequences system unix
environment io.encodings.utf8 unix.utilities vocabs
combinators alien.accessors unix.ffi ;
USING: alien.accessors alien.c-types alien.data alien.strings
alien.syntax environment io.encodings.utf8 kernel libc system unix.ffi
unix.utilities vocabs ;
IN: environment.unix
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 (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 ;

View File

@ -2,9 +2,9 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.c-types alien.data alien.strings assocs
classes.struct continuations fry io.backend io.backend.unix
io.directories io.encodings.utf8 io.files io.files.info
io.files.info.unix io.files.types kernel libc literals math
sequences system unix unix.ffi vocabs ;
io.directories io.files io.files.info io.files.info.unix
io.files.types kernel libc literals math sequences system unix
unix.ffi vocabs ;
IN: io.directories.unix
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
: >directory-entry ( dirent* -- directory-entry )
[ d_name>> utf8 alien>string ]
[ d_name>> alien>native-string ]
[ d_type>> dirent-type>file-type ] bi
dup +unknown+ = [ drop dup file-info type>> ] when
<directory-entry> ; inline