Function: file-modes-char-to-right

file-modes-char-to-right is a byte-compiled function defined in files.el.gz.

Signature

(file-modes-char-to-right CHAR &optional FROM)

Documentation

Convert CHAR to a numeric value of mode bits.

CHAR is in [rwxXstugo] and represents symbolic access permissions. If CHAR is in [Xugo], the value is taken from FROM (or 0 if omitted).

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun file-modes-char-to-right (char &optional from)
  "Convert CHAR to a numeric value of mode bits.
CHAR is in [rwxXstugo] and represents symbolic access permissions.
If CHAR is in [Xugo], the value is taken from FROM (or 0 if omitted)."
  (or from (setq from 0))
  (cond ((= char ?r) #o0444)
	((= char ?w) #o0222)
	((= char ?x) #o0111)
	((= char ?s) #o6000)
	((= char ?t) #o1000)
	;; Rights relative to the previous file modes.
	((= char ?X) (if (= (logand from #o111) 0) 0 #o0111))
	((= char ?u) (let ((uright (logand #o4700 from)))
		       ;; FIXME: These divisions/shifts seem to be right
                       ;; for the `7' part of the #o4700 mask, but not
                       ;; for the `4' part.  Same below for `g' and `o'.
		       (+ uright (/ uright #o10) (/ uright #o100))))
	((= char ?g) (let ((gright (logand #o2070 from)))
		       (+ gright (/ gright #o10) (* gright #o10))))
	((= char ?o) (let ((oright (logand #o1007 from)))
		       (+ oright (* oright #o10) (* oright #o100))))
        (t (error "%c: Bad right character" char))))