2010-12-17 17:23:59 +03:00
|
|
|
#include <ctype.h>
|
2010-12-17 20:28:33 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2010-12-17 19:07:40 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || \
|
|
|
|
defined(__BORLANDC__) || defined(__MINGW32__))
|
2010-10-26 14:06:15 +04:00
|
|
|
|
|
|
|
#include <direct.h>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <io.h>
|
2010-10-26 14:06:15 +04:00
|
|
|
|
|
|
|
#if defined(__WATCOMC__)
|
|
|
|
#include <direct.h>
|
|
|
|
#define _getcwd getcwd
|
|
|
|
#endif
|
|
|
|
|
2010-12-17 20:28:33 +03:00
|
|
|
static const char* Getcwd(char* buf, unsigned int len)
|
2010-10-26 14:06:15 +04:00
|
|
|
{
|
|
|
|
const char* ret = _getcwd(buf, len);
|
2010-12-17 20:28:33 +03:00
|
|
|
char* p = NULL;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ret) {
|
2010-12-17 20:28:33 +03:00
|
|
|
fprintf(stderr, "No current working directory.\n");
|
2010-10-26 14:06:15 +04:00
|
|
|
abort();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-10-26 14:06:15 +04:00
|
|
|
// make sure the drive letter is capital
|
2016-05-16 17:34:04 +03:00
|
|
|
if (strlen(buf) > 1 && buf[1] == ':') {
|
2010-10-26 14:06:15 +04:00
|
|
|
buf[0] = toupper(buf[0]);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (p = buf; *p; ++p) {
|
|
|
|
if (*p == '\\') {
|
2010-12-17 17:45:39 +03:00
|
|
|
*p = '/';
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-10-26 14:06:15 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#include <fcntl.h>
|
2016-05-02 22:09:33 +03:00
|
|
|
#include <sys/types.h>
|
2010-10-26 14:06:15 +04:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2010-12-17 20:28:33 +03:00
|
|
|
static const char* Getcwd(char* buf, unsigned int len)
|
2010-10-26 14:06:15 +04:00
|
|
|
{
|
|
|
|
const char* ret = getcwd(buf, len);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ret) {
|
2010-12-17 20:28:33 +03:00
|
|
|
fprintf(stderr, "No current working directory\n");
|
2010-10-26 14:06:15 +04:00
|
|
|
abort();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2010-10-26 14:06:15 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
int main(int argc, char* argv[])
|
2010-10-26 14:06:15 +04:00
|
|
|
{
|
|
|
|
char buf[2048];
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cwd = Getcwd(buf, sizeof(buf));
|
2010-10-26 14:06:15 +04:00
|
|
|
|
2011-01-03 16:39:22 +03:00
|
|
|
return strcmp(cwd, argv[1]);
|
2010-10-26 14:06:15 +04:00
|
|
|
}
|