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
|
|
|
|
2010-10-26 14:06:15 +04:00
|
|
|
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
|
|
|
|
|
|
|
|
#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;
|
2010-10-26 14:06:15 +04: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();
|
|
|
|
}
|
|
|
|
// make sure the drive letter is capital
|
|
|
|
if(strlen(buf) > 1 && buf[1] == ':')
|
|
|
|
{
|
|
|
|
buf[0] = toupper(buf[0]);
|
|
|
|
}
|
2010-12-17 20:28:33 +03:00
|
|
|
for(p = buf; *p; ++p)
|
2010-12-17 17:45:39 +03:00
|
|
|
{
|
|
|
|
if(*p == '\\')
|
|
|
|
{
|
|
|
|
*p = '/';
|
|
|
|
}
|
|
|
|
}
|
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);
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
char buf[2048];
|
|
|
|
const char *cwd = Getcwd(buf, sizeof(buf));
|
|
|
|
|
2011-01-03 16:39:22 +03:00
|
|
|
return strcmp(cwd, argv[1]);
|
2010-10-26 14:06:15 +04:00
|
|
|
}
|