//===========================================================================//
// File:     fileutil.hh                                                     //
// Title:    General File Utilities                                          //
// Project:  Tool Architecture II                                            //
// Author:   Jerry Edsall                                                    //
// Purpose:  Provide mechanism for keeping work directories                  //
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 02/23/95	 JSE  Initial Coding															  //
// 03/01/95  KEO  Cleanup and enhancements.                                  //
//---------------------------------------------------------------------------//
// Copyright (c) 1995 Virtual World Entertainment, Inc.                      //
//   All rights reserved worldwide.                                          //
// This unpublished source code is PROPRIETARY and CONFIDENTIAL.             //
//===========================================================================//

#if !defined(FILEUTIL_HPP)
	#define FILEUTIL_HPP

	//---------------
	// munga headers
	//---------------
	#if !defined(STYLE_HPP)
		#include <style.hpp>
	#endif

	#if !defined(SCALAR_HPP)
		#include <scalar.hpp>
	#endif

	class NotationFile;

	extern char *WorkingDirectory;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	extern const char *White_Space;

	inline char*
		NextToken()
			{ return strtok(NULL, White_Space); }

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	void
		SetSourceDirectory(const char *input_file);
	void
		SetOutputDirectory(const char *directory);
	const char*
		GetSourceDirectory();
	const char*
		GetConfigDirectory();
	const char*
		GetMaterialDirectory();
	const char*
		GetTextureDirectory();
	const char*
		GetAnimationDirectory();
	const char*
		GetProductionDirectory();
	const char*
		GetOutputDirectory();
	void
		ClearDirectories();
	const char*
		SourceFile(
			const char *filename,
			const char *extension = NULL
		);
	const char*
		ConfigFile(
			const char *filename,
			const char *extension = NULL
		);
	const char*
		MaterialFile(
			const char *filename,
			const char *extension = NULL
		);
	const char*
		TextureFile(
			const char *filename,
			const char *extension = NULL
		);
	const char*
		AnimationFile(
			const char *filename,
			const char *extension = NULL
		);
	const char*
		OutputFile(
			const char *filename,
			const char *extension = NULL
		);
	const char*
		StripDirectory(const char *filename);
	const char*
		StripExtension(const char *filename);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	char*
		Ind(int level = 1);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	Logical
		GetLine(
			istream &stream,
			char *buffer,
			int size_of_buffer
		);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#if 0
	char*
		stripname(char filename[]);
#endif

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	Scalar
		D2R(float degrees);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	char*
		MakeWorkingDirectory(
			const char *file
		);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	Logical
		DirectoryIsSpecified(
			const char *file
		);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	char*
		MakePathedFilename(
			const char *directory,
			const char *name
		);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	void
		OpenOutput(
			ofstream &stream,
			const char *directory,
			const char *filename
		);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	void
		OpenInput(
			ifstream &stream,
			char *directory,
			const char *filename
		);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

	Logical
		DoesNotationFileExist(
			NotationFile
				*notation_file
		);

#endif

//=============================================================================
