I'm trying to port my program over to windows using visual c++ express as my compiler. Why I really don't know, I guess to allow my friends (who won't try Linux for nothing) to test and use it. I want it to be capable of being built on either system. I've ran into a couple of problems and was seeking some help.
1.) Windows doesn't use file permission, well at least to my knowledge and I have all these errors.
"error C2065: 'F_OK' : undeclared identifier"
"error C2065: 'mode_t' : undeclared identifier"
etc... I know that I will have to find a way to 'by pass' these permission sections in my code, but how. I know that windows compilers define a preprocessor directive WIN32, so I could use something similar to this to test if it is being built on windows.
#ifdef WIN32
....
#endif
I know that I could include different files this way (that don't include these permissions, but that would be a LOT of work. Is there any shortcuts to this?
2.) I also have a couple functions that test if a path points to a file or a directory. Here's a sample:
Code:
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
using namespace std;
bool isdirectory(string path)
{
bool test = false;
struct stat stats;
if (!stat(path.c_str(), &stats)) {
if (S_ISDIR(stats.st_mode)) {
test = true;
}
}
return test;
}
bool isfile(string path)
{
bool test = false;
struct stat stats;
if (!stat(path.c_str(), &stats)) {
if (S_ISREG(stats.st_mode)) {
test = true;
}
}
return test;
}
But this results in these errors:
"error C3861: 'S_ISDIR': identifier not found"
"error C3861: 'S_ISREG': identifier not found"
Is there a different way to preform these test under win32?
THANKS in advance!!!
Bendeco