Domanda

I have implemented a TFTP on top of UDP in C, and I am trying to figure out how to check the read/write permission on the directory that transfer is going to take place. For the existence of the file and the case that file doesn't exist I have used access() with F_OK, but W_OK and R_OK seem to be troublesome when trying to check the permission on the directory, I have looked at stat(), but failed to implement it correctly. Any ideas on alternatives or correct implementation of the stat() or access() for the directory not the file.

È stato utile?

Soluzione

Idea of an alternative: You don't need to check the permission for the directory; just try to open the file, and send the resulting error code.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top