Hey guys,


I hate asking this but unfortunetly, Google does not know how to interpret "|" and probably assumes its an OR command or something :P . The line goes as follows (source found http://pysnippet.blogspot.com/2009/11/fuse-filesystem-in-userspace-part-1.html here):

st.st_mode = stat.S_IFDIR | 0755

I know it's doing something about the mode being 0755 but I have never seen | be used like that before.

Can someone explain whats going on?


Thanks!

The single vertical bar is for the bitwise OR operator. What the code is doing is taking the S_IFDIR flag (which indicates if a given file handle is actually for a directory), and overlaying the bitfield for the desired file permissions, which results in the overall file mode value. See here and here for more details.

commented: Very informative post +2

The single vertical bar is for the bitwise OR operator. What the code is doing is taking the S_IFDIR flag (which indicates if a given file handle is actually for a directory), and overlaying the bitfield for the desired file permissions, which results in the overall file mode value. See here and here for more details.

That helped me out, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.