Skip to content

Instantly share code, notes, and snippets.

@afazio
Last active December 14, 2015 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afazio/4998363 to your computer and use it in GitHub Desktop.
Save afazio/4998363 to your computer and use it in GitHub Desktop.
Compile: "gcc -o main main.c" Call: "./main /path/to/some/file/or/directory"
#include <stdio.h>
#include <unistd.h>
int main (int argc, char** argv) {
char* path = argv[1];
printf ("Checking write permissions for %s:\n", path);
int result = access(path, W_OK);
printf ("User %s have write permissions.\n", (result == -1 ? "does NOT" : "DOES"));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment