Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


st_mode confusion

This topic is 5993 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to figure out stat.h, the part where the mode bits are set for the file access permissions. I have found the following information. http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_278.html#SEC287 Only problem is I can''t make head or tails of it, can someone help me by providing an example or something??

Share this post

Link to post
Share on other sites
Ok i''ve written my interpretation of the mode bits. Basically what the following code snippet should do is check if the bit representing read permissions for the user is set, then it should print an "r" else it will print "-".

struct stat sbuf;
mode_t mode;

if(argv[1] !=''\0''){
if(lstat(argv[1],&sbuf) != -1){
mode = sbuf.st_mode;
if(mode == S_IRUSR)
printf("Can''t stat %s\n", argv[1]);
printf("Usage:%s file_name\n",argv[0]);

Share this post

Link to post
Share on other sites
You really should stop cross posting here and General Programming. Pick a forum and stick with it.

Also, you''ve been asking a lot of basic UNIX architecture/programming questions. I suggest you peruse your local public/university library for several excellent references. It''ll be faster for you, will give you broader information on more topics, and will then allow you use this forum for interesting specific application questions - which means you''ll get better answers.

That''s my recommendation, at least.

I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!