Jump to content
  • Advertisement
Sign in to follow this  
attahollander

2 basic questions

This topic is 4010 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

2 basic questions: 1) is the a function in glibc to find out if a file is an executable ? 2) is it possible to store the gcc output (errors/warnings) in a file?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by attahollander
1) is the a function in glibc to find out if a file is an executable ?

To find out if a file (or directory) has execute permissions would be stat.

#include <sys/stat.h>
#include <stdio.h>

int main(void) {
const char path[] = "/tmp/somefile";
struct stat buf;

if(stat(path, &buf)) {
printf("Error calling stat.\n");
return 1;
}

printf("%s is executable by:\n\tuser: %s\n\tgroup: %s\n\tothers: %s\n",
path,
(buf.st_mode & S_IXUSR) ? "yes" : "no",
(buf.st_mode & S_IXGRP) ? "yes" : "no",
(buf.st_mode & S_IXOTH) ? "yes" : "no");

return 0;
}




Quote:
Original post by attahollander
2) is it possible to store the gcc output (errors/warnings) in a file?

It depends on your shell, but most support redirection of the form "command &> /tmp/outputfile". You can also redirect just errors with "command 2> /tmp/outputfile".

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!