Changeset 8067 in project


Ignore:
Timestamp:
02/02/08 18:19:33 (11 years ago)
Author:
sjamaan
Message:

Add TODO note about 9p:rename-file to the top
Add some blob stuff to 9p:file-read to circumvent possible utf8 usage and document why we did this
Remove utf8 from lolevel egg (user is expected to make the tradeoff to use utf8 or not)

Location:
release/3/9p/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/3/9p/trunk/9p-client.scm

    r8066 r8067  
    3333; ticket tracking system (assign tickets to user 'sjamaan'):
    3434; http://trac.callcc.org
     35;
     36; TODO: 9p:rename-file.  Unfortunately, 9p has no native 'move' command, so
     37; this will be hard and very error-prone to do, at least in the case of directories.
     38; Something for another time :)
    3539
    3640(use 9p-lolevel srfi-13 iset)
     
    349353      (9p:request con 'Tremove (9p:handle-fid h)) (9p:release-handle h))))
    350354
    351 ;; TODO: 9p:rename-file
    352 
    353355(define (9p:read-directory h show-dotfiles?)
    354356  (let loop ((result (list))
     
    380382  (9p:call-with-output-file con file (lambda (p) (parameterize ((current-output-port p)) (thunk)))))
    381383
    382 ;; XXX Is a character a real character (utf8 can mean more than 1 byte) or just 1 byte?
    383384(define (9p:open-input-file con file)
    384385  (let* ((h (9p:file-open con file 9p:open/rdonly))
     
    386387         (buffer-offset 0)
    387388         (buffer-size 0))
    388     ;; XXX Use a string port for the buffer and read from that
    389389    (make-input-port (lambda ()
     390                       ; This procedure does some string/blob/u8vector gymnastics so it returns raw
     391                       ; byte characters both when utf8 is loaded and when it's not.
     392                       ; The highlevel "read" procedures are overridden by utf8, but low-level
     393                       ; procedures are still expected to return byte-chars.  That's why we can't
     394                       ; use string-ref here (because it may really be utf8's string-ref).
    390395                       (if buffer
    391                            (let ((char (string-ref buffer buffer-offset)))
     396                           (let ((char (integer->char (u8vector-ref buffer buffer-offset))))
    392397                            (set! buffer-offset (add1 buffer-offset))
    393398                            (when (= buffer-offset buffer-size)
     
    398403                             (cond
    399404                              ((zero? (second result)) #!eof)
    400                               ((= (second result) 1) (string-ref (car result) 0))
    401                               (else (set! buffer (car result))
     405                              ((= (second result) 1) (integer->char (u8vector-ref (blob->u8vector/shared (string->blob (car result))) 0)))
     406                              (else (set! buffer (blob->u8vector/shared (string->blob (car result))))
    402407                                    (set! buffer-size (second result))
    403408                                    (set! buffer-offet 1)
    404                                     (string-ref buffer 0))))))
     409                                    (integer->char (u8vector-ref buffer 0)))))))
    405410                     (constantly #t)
    406411                     (lambda ()
  • release/3/9p/trunk/9p-lolevel.scm

    r8057 r8067  
    3939;; Possibly this is more efficient.
    4040
    41 (use srfi-1 srfi-4 srfi-8 srfi-18 posix) ; utf8
    42 
    43 ;; XXX Wrap in a module!
    44 ;(import utf8)
     41(use srfi-1 srfi-4 srfi-8 srfi-18 posix)
    4542
    4643(define-record 9p-qid
Note: See TracChangeset for help on using the changeset viewer.