You probably don’t care about Unix File Mode & octmode bitwise comparison but let’s talk about it anyway

Wait 5 sec.

[This article was first published on Colin Fay, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't. For some reason during the summer holidays I was browsing the R source code and stumbled upon this piece of code in check_permissions.## Phase A. Directories at least 700, files at least 400.if (length(allfiles)) { mode = 400 will start with 1xx xxx xxx so will always be != 0 because400 = 100 000 000??? = 1xx xxx xxx-------------------400 = 100 000 000So basically (mode & "400") is a way to do some triage, so that every perm below 400 will be converted to 0, and the others to 400.< as.octmode("400")Now that we know what (mode & "400") does, the end of the expression is pretty straightforward.After the &, we only have two possible values: 000 or 400. And < as.octmode("400") is TRUE only for 000, i.e. for the files the owner can’t read.modes