Create a gist now

Instantly share code, notes, and snippets.

@afazio /main.c
Last active Dec 14, 2015

What would you like to do?
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