Sense or Nonsense!?

16.07.2009

THE missing functions in windows …

Filed under: Windows — Ephraim @ 15:15

Here are the two functions I often missed in the windows C/C++ libraries …

#include <sys/types.h>
#include <sys/stat.h>

bool file_exists(const TCHAR* lspzFile) {
	int i;
	struct _stat s;

	if(!lspzFile) return false;

	i = _tstat(lspzFile, &s);

	if(!i && (s.st_mode & _S_IFREG) != 0)
		return true;
	else
		return false;
}

bool dir_exists(const TCHAR* lspzDirectory) {
	int i;
	struct _stat s;

	if(!lspzDirectory) return false;

	i = _tstat(lspzDirectory, &s);

	if(!i && (s.st_mode & _S_IFDIR) != 0)
		return true;
	else
		return false;
}

Ciao Ephraim

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress