#include <stdio.h>
#include <dir.h>
#include <egb.h>
#include "filesel.h"

#define ERR		1
#define NOERR	0

char	egbwork[1536];
char	moswork[4096];

void	init()
{
	EGB_init( egbwork, 1536 );
	EGB_resolution( egbwork, 1, 3 );
	EGB_writePage( egbwork, 1 );

	MOS_start( moswork );

	return;
}

void	end()
{
	MOS_end();
	screenterm( egbwork );
	return;
}

int		main( int argc, char *argv[] )
{
	char	path[256];
	char	*allfile = "*.*";
	char	*wild;
	int		size;

	init();

	if( argc > 1 )
		wild = argv[1];
	else
		wild = allfile;


	FS_locate( 0, 0 );

	while(1)
	{
		if( FS_fileSelect( egbwork, wild, path ) )
		{
			printf( "program end.\n" );
			end();
			return NOERR;
		}
		else
		{
			if( ( size = _get_file_size( path ) ) < 0 )
			{
				printf( "\"%s\" cannot found.\n", path );
				end();
				return ERR;
			}
			printf( "select file = \"%s\"\n", path );
			printf( "filesize    = %d (byte)\n", size );
		}
	}
}
