//	Zinc Application Framework - Z_UNISTD.CPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#include <z_unistd.hpp>
#include <z_cset.hpp>

#if defined(ZAF_UNICODE)
#	include "u_unistd.cpp"
#elif defined(ZAF_ISO8859_1)
#include <z_string.hpp>

#if defined(ZAF_VXWORKS)
#undef rename
#undef remove
#undef unlink
#include <stdio.h>
#endif

int ZafChDir(const ZafIChar *path)
{
	char mappedPath[ZAF_MAXPATHLEN];
	ZafConvertToOSString(path, mappedPath, false);
#undef chdir
	return OSchdir(mappedPath);
}

ZafIChar *ZafGetCwd(ZafIChar *path, unsigned int)
{
	static char mappedPath[ZAF_MAXPATHLEN];
#if defined(ZAF_PSOS)
	strcpy(mappedPath, "/");
	ZafConvertToOSString(mappedPath, path, false);
	return path;
#else
#undef getcwd
	if (OSgetcwd(mappedPath, ZAF_MAXPATHLEN))
	{
		ZafConvertToOSString(mappedPath, path, false);
		return path;
	}
#endif
	return ZAF_NULLP(ZafIChar);
}

int ZafRename(const ZafIChar *oldPath, const ZafIChar *newPath)
{
	char mappedOldPath[ZAF_MAXPATHLEN], mappedNewPath[ZAF_MAXPATHLEN];
	ZafConvertToOSString(oldPath, mappedOldPath, false);
	ZafConvertToOSString(newPath, mappedNewPath, false);
#undef rename
	return OSrename(mappedOldPath, mappedNewPath);
}

int ZafUnlink(const ZafIChar *path)
{
	char mappedPath[ZAF_MAXPATHLEN];
	ZafConvertToOSString(path, mappedPath, false);
#undef unlink
	return OSunlink(mappedPath);
}
#else
	// We use the compiler's library for OEM characters
#endif
