2007-02-19 20:23:37 +03:00
|
|
|
#include <stdio.h>
|
2016-05-16 17:34:04 +03:00
|
|
|
#include <stdlib.h>
|
2007-02-19 20:23:37 +03:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <io.h>
|
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// return true if the file exists
|
|
|
|
int FileExists(const char* filename)
|
|
|
|
{
|
|
|
|
#ifdef _MSC_VER
|
2016-05-16 17:34:04 +03:00
|
|
|
#define access _access
|
2007-02-19 20:23:37 +03:00
|
|
|
#endif
|
|
|
|
#ifndef F_OK
|
|
|
|
#define F_OK 0
|
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
if (access(filename, F_OK) != 0) {
|
2007-02-19 20:23:37 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2007-02-19 20:23:37 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-19 20:23:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int ac, char** av)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ac <= 1) {
|
2007-02-19 20:23:37 +03:00
|
|
|
printf("Usage: %s <file>\n", av[0]);
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!FileExists(av[1])) {
|
2007-02-19 20:23:37 +03:00
|
|
|
printf("Missing file %s\n", av[1]);
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (FileExists(av[2])) {
|
2007-02-19 20:23:37 +03:00
|
|
|
printf("File %s should be in subdirectory\n", av[2]);
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-02-19 20:23:37 +03:00
|
|
|
printf("%s is not there! Good.", av[2]);
|
|
|
|
printf("%s is there! Good.", av[1]);
|
|
|
|
return 0;
|
|
|
|
}
|