/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


		#include "import/import_interface.h"
		#include "filesystem/filesystem.h"
		#include "platform.h"

		using GS::String;
		using namespace GS::S3D;


//------------------------------------------------------------------------------
bool			IImport::GetOutputPath(String &path, const String &base, const char *name, const char *dflt, const char *ext, Config::PathExistsPolicy exist_policy) const
{
	if	(base.IsEmpty())
		return false;

	if	(!name)
		name = dflt;

	path = String::Format("%s/%s.%s", base.c_str(), name, ext);

	switch (exist_policy)
	{
		case Config::Overwrite:
			return true;

		case Config::Skip:
			if	(Platform::Get().io->Exists(path))
				return false;
			break;

		case Config::Rename:
			for	(uint n = 0; Platform::Get().io->Exists(path) && (n < 10000); ++n)
				path = String::Format("%s/%s-%04d.%s", base.c_str(), name, n, ext);
			break;

		default: break;
	}
	return true;
}
//------------------------------------------------------------------------------
