Whether there's sufficient space left is normally not a concern of the directory but of the whole file system. There are things like quotas, which are normally supported by default by any distributor-made standard kernel but which have to be activated first.
So, I guess a call to statvfs() should do it.