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