2004-03-10 00:20:41 +03:00
|
|
|
#include <stdio.h>
|
2016-05-16 17:34:04 +03:00
|
|
|
#include <stdlib.h>
|
2004-03-10 00:28:44 +03:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <io.h>
|
|
|
|
#else
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2004-03-10 00:20:41 +03:00
|
|
|
|
|
|
|
// 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
|
2004-03-10 00:20:41 +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) {
|
2004-03-10 00:20:41 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2004-03-10 00:20:41 +03:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-03-10 00:20:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int ac, char** av)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ac <= 1) {
|
2004-04-27 01:32:56 +04:00
|
|
|
printf("Usage: %s <file>\n", av[0]);
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!FileExists(av[1])) {
|
2004-03-10 00:20:41 +03:00
|
|
|
printf("Missing file %s\n", av[1]);
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (FileExists(av[2])) {
|
2004-04-27 01:32:56 +04:00
|
|
|
printf("File %s should be in subdirectory\n", av[2]);
|
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-04-27 01:32:56 +04:00
|
|
|
printf("%s is not there! Good.", av[2]);
|
|
|
|
printf("%s is there! Good.", av[1]);
|
2004-03-10 00:20:41 +03:00
|
|
|
return 0;
|
|
|
|
}
|