unlink() – FamilyTree

I have recently bought a new laptop and hence it does not have Ubuntu installed in it. Since I am currently working with *AMP stack which also works on Windows. So I started with Windows as of now.

So this post was to write about the issue that I faced recently while I was working on FamilyTree. So while installation of FamilyTree, it checks for required folder permissions by creating a file in the given folder. If it is able to then we have the permission else we don’t.

The code was working for past 4 year I think. Now I was getting a permission denied error. So I checked permission which were all fine, but still it was not working.

So my function was able to create test lock file in the folder but not able to delete it. But how is this possible, if it able to create a file, then we should have access to delete it also.

Then after 4 days I noticed that I was not closing the file handle which would create the file for me. So I did fclose() and it started working.

The code has been tested on Linux, Windows 7 and Mac. They both allow deleting of the file even if the file handle in open. But Windows 10 denied deleting the file up until the file handle was closed.

Now I don’t know whether to applaud Microsoft for this or not. 😛 But yes it made me figure my mistake So I think I should. Thanks Microsoft.

Leave a comment