Question

I am using CGYWIN gcc (4.8.2) and I am doing a very basic file open and write, but the resulting file has permissions that make it inaccessible to Windows. I don't understand why, and how can I fix this?

// a bunch of curl stuff (CURLOPT_WRITEFUNCTION is write_data)
file = fopen(filename, "wb");
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
    size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
    return written;
}

The resulting file according to CGYWIN terminal is -rw-r--r-- but the file that I end up writing needs executable permissions, and I don't understand why the default on Windows doesn't have executable permissions?

Was it helpful?

Solution

Windows' permissions are very different from Linux's, it uses the ACL model that allows a access control far more sophisticated than Linux's, and it can hardly be translated into this simpleton rwxrwxrwx flag set. But ironically Windows' ACL don't make distinction between "permission to read" and "permission to execute", to it it's the same thing. Perhaps Cygwin has it's own way of representing that, but I don't think thats the issue here. If you want to write to the file, you only need permission to write.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top