Function: tramp-mode-string-to-int
tramp-mode-string-to-int is a byte-compiled function defined in
tramp.el.gz.
Signature
(tramp-mode-string-to-int MODE-STRING)
Documentation
Convert a ten-letter "drwxrwxrwx"-style MODE-STRING into mode bits.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp.el.gz
;; See also `file-modes-symbolic-to-number'.
(defun tramp-mode-string-to-int (mode-string)
"Convert a ten-letter \"drwxrwxrwx\"-style MODE-STRING into mode bits."
(let* (case-fold-search
(mode-chars (string-to-vector mode-string))
(owner-read (aref mode-chars 1))
(owner-write (aref mode-chars 2))
(owner-execute-or-setid (aref mode-chars 3))
(group-read (aref mode-chars 4))
(group-write (aref mode-chars 5))
(group-execute-or-setid (aref mode-chars 6))
(other-read (aref mode-chars 7))
(other-write (aref mode-chars 8))
(other-execute-or-sticky (aref mode-chars 9)))
(logior
(cond
((char-equal owner-read ?r) #o0400)
((char-equal owner-read ?-) 0)
(t (error "Second char `%c' must be one of `r-'" owner-read)))
(cond
((char-equal owner-write ?w) #o0200)
((char-equal owner-write ?-) 0)
(t (error "Third char `%c' must be one of `w-'" owner-write)))
(cond
((char-equal owner-execute-or-setid ?x) #o0100)
((char-equal owner-execute-or-setid ?S) #o4000)
((char-equal owner-execute-or-setid ?s) #o4100)
((char-equal owner-execute-or-setid ?-) 0)
(t (error "Fourth char `%c' must be one of `xsS-'"
owner-execute-or-setid)))
(cond
((char-equal group-read ?r) #o0040)
((char-equal group-read ?-) 0)
(t (error "Fifth char `%c' must be one of `r-'" group-read)))
(cond
((char-equal group-write ?w) #o0020)
((char-equal group-write ?-) 0)
(t (error "Sixth char `%c' must be one of `w-'" group-write)))
(cond
((char-equal group-execute-or-setid ?x) #o0010)
((char-equal group-execute-or-setid ?S) #o2000)
((char-equal group-execute-or-setid ?s) #o2010)
((char-equal group-execute-or-setid ?-) 0)
(t (error "Seventh char `%c' must be one of `xsS-'"
group-execute-or-setid)))
(cond
((char-equal other-read ?r) #o0004)
((char-equal other-read ?-) 0)
(t (error "Eighth char `%c' must be one of `r-'" other-read)))
(cond
((char-equal other-write ?w) #o0002)
((char-equal other-write ?-) 0)
(t (error "Ninth char `%c' must be one of `w-'" other-write)))
(cond
((char-equal other-execute-or-sticky ?x) #o0001)
((char-equal other-execute-or-sticky ?T) #o1000)
((char-equal other-execute-or-sticky ?t) #o1001)
((char-equal other-execute-or-sticky ?-) 0)
(t (error "Tenth char `%c' must be one of `xtT-'"
other-execute-or-sticky))))))