Ignore:
Timestamp:
Nov 4, 2010, 2:09:15 AM (9 years ago)
Author:
rme
Message:

Update %RMDIR to remove a trailing #\/ at the lisp level, instead of
doing C-style tricks.

On a Windows system, WITH-FILENAME-CSTRS produces a UTF-16LE-encoded
string, where each character corresponds to (at least) two bytes.

Consider the following case:

(defparameter *name* (format nil "c:/~czz/" #\u+2f2f))
(%mkdir *name* #o666)
(%rmdir *name*) => returns non-zero

The trailing #\/ is at index 6. The old code would therefore look at
byte offset 6, which, in this contrived example, is #x2f, or in other
words, (char-code #\/). The code replacs it with a #\null, and
confusion ensues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/linux-files.lisp

    r14351 r14404  
    296296(defun %rmdir (name)
    297297  (let* ((last (1- (length name))))
     298    (when (and (>= last 0)
     299               (eql (char name last) #\/))
     300      (setq name (subseq name 0 last)))
    298301    (with-filename-cstrs ((name name))
    299       (when (and (>= last 0)
    300                  (eql (%get-byte name last) (char-code #\/)))
    301         (setf (%get-byte name last) 0))
    302302      (int-errno-call (#+windows-target #__wrmdir #-windows-target #_rmdir  name)))))
    303303
Note: See TracChangeset for help on using the changeset viewer.