Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This might make me look like a pervert, but I searched google for 'sperm' (ofcourse only for .h and .cpp files). The bad news is I can't find any references to it (except on the <a href="http://pubs.opengroup.org/onlinepubs/007904975/functions/stat.html" rel="noreferrer">stat function</a> page itself).</p> <p>The good news is I found <a href="http://code.google.com/p/group1reseau/source/browse/trunk/ftp_server/FTPProcess.cpp?spec=svn11&amp;r=11" rel="noreferrer">this</a> piece of code which defines it's own 'sperm' function:</p> <pre><code>char const * sperm(__mode_t mode) { static char local_buff[16] = {0}; int i = 0; // user permissions if ((mode &amp; S_IRUSR) == S_IRUSR) local_buff[i] = 'r'; else local_buff[i] = '-'; i++; if ((mode &amp; S_IWUSR) == S_IWUSR) local_buff[i] = 'w'; else local_buff[i] = '-'; i++; if ((mode &amp; S_IXUSR) == S_IXUSR) local_buff[i] = 'x'; else local_buff[i] = '-'; i++; // group permissions if ((mode &amp; S_IRGRP) == S_IRGRP) local_buff[i] = 'r'; else local_buff[i] = '-'; i++; if ((mode &amp; S_IWGRP) == S_IWGRP) local_buff[i] = 'w'; else local_buff[i] = '-'; i++; if ((mode &amp; S_IXGRP) == S_IXGRP) local_buff[i] = 'x'; else local_buff[i] = '-'; i++; // other permissions if ((mode &amp; S_IROTH) == S_IROTH) local_buff[i] = 'r'; else local_buff[i] = '-'; i++; if ((mode &amp; S_IWOTH) == S_IWOTH) local_buff[i] = 'w'; else local_buff[i] = '-'; i++; if ((mode &amp; S_IXOTH) == S_IXOTH) local_buff[i] = 'x'; else local_buff[i] = '-'; return local_buff; } </code></pre> <p>usage is simple:</p> <pre><code>#include &lt;sys/types.h&gt; #include &lt;sys/stat.h&gt; #include &lt;iostream&gt; int main(int argc, char ** argv) { std::cout&lt;&lt;sperm(S_IRUSR | S_IXUSR | S_IWGRP | S_IROTH)&lt;&lt;std::endl; std::cout&lt;&lt;sperm(S_IRUSR)&lt;&lt;std::endl; std::cout&lt;&lt;sperm(S_IRUSR | S_IRGRP | S_IWOTH | S_IROTH)&lt;&lt;std::endl; return 0; } </code></pre> <p>output on <a href="http://ideone.com/C9USp" rel="noreferrer">ideone</a>:</p> <pre><code>r-x-w-r-- r-------- r--r--rw- </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload