title: Check if a folder is writable
body: <p>I'm writing an simple file server using sockets for an assignment. Before I start accepting connections I need to check that the server can write to the requested directory it serves from.</p>
  
  <p>One simple way of doing this would simply be to try create a file and then delete it straight afterwards and error if that failed. But what if the file already exists? My program crashes or gets closed in-between? Along with the fact it seems a bit messy and isn't elegant.</p>
  
  <p>Strictly speaking the code only needs to work for an Ubuntu system the markers test it on. So I could do a stat() command, get the current uid and gid and check the permissions manually against the file status. But I'd rather do this in a portable fashion and this is laborous..</p>
  
  <p>Is there a simple <code>C</code> standard way of doing this?</p>