the source of files.dll

Code:
#include "stdafx.h"
#define DLL_USE
#include "adll.h"
#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <io.h>
#include <time.h>


BOOL APIENTRY DllMain( 
  HANDLE hModule,
  DWORD ul_reason_for_call,
  LPVOID lpReserved)
{
  engine_bind();
  return TRUE;
}


// get the file attributes
DLLFUNC file_attrib(STRING* filepath,var funcmode)
{
	struct _finddata_t c_file;
	long lFile=0;
	lFile=_findfirst( _CHR(filepath), &c_file );
	if(lFile<0){return _VAR(-1);}
	if(funcmode==0){return ((c_file.attrib & _A_RDONLY) ? _VAR(1) : _VAR(0));}
	if(funcmode==1){return ((c_file.attrib & _A_HIDDEN) ? _VAR(1) : _VAR(0));}
	if(funcmode==2){return ((c_file.attrib & _A_SYSTEM) ? _VAR(1) : _VAR(0));}
	if(funcmode==3){return ((c_file.attrib & _A_ARCH) ? _VAR(1) : _VAR(0));}
}

//listing all files in the folder, \n as seperator
DLLFUNC file_list(STRING* wildcard,STRING* buf)
{
	struct _finddata_t c_file;
	long lFile=0;
	lFile=_findfirst( _CHR(wildcard), &c_file );
	if(lFile<0){return 0;}
	str_cpy(buf,c_file.name);
	str_cat(buf,"\n");
	while(_findnext(lFile,&c_file)==0)
	{
		str_cat(buf,c_file.name);
		str_cat(buf,"\n");
	}
}

//get the filenames from a directory
DLLFUNC file_get(STRING* wildcard, var number)
{
	static STRING *buf = (STRING*)engine_getobj("foundfile");
	struct _finddata_t c_file;
	long lFile=0;
	int stop = _INT(number);
	int i=2;
	lFile=_findfirst( _CHR(wildcard), &c_file );
	if(lFile<0){return _VAR(0);}
	if(stop==1){str_cpy(buf,c_file.name); return _VAR(1);}

	while((_findnext(lFile,&c_file)==0)&&(stop!=i))
	{
		i++;
	}
	str_cpy(buf,c_file.name);
	return _VAR(1);
}

//count all files
DLLFUNC file_count(STRING* dir)
{
	struct _finddata_t c_file;
	long lFile=0;
	int i=1;
	int j=0;
	lFile=_findfirst( _CHR(dir), &c_file );
	if(lFile<0){return _VAR(0);}
	j+=(c_file.attrib & _A_SUBDIR) ? 0 : 1;
	while(_findnext(lFile,&c_file)==0)
	{
		j+=(c_file.attrib & _A_SUBDIR) ? 0 : 1;
		i++;
	}
	return _VAR(j);
}

//count subfolders
DLLFUNC folder_count(STRING* dir)
{
	struct _finddata_t c_file;
	long lFile=0;
	int i=1;
	int j=0;
	lFile=_findfirst( _CHR(dir), &c_file );
	if(lFile<0){return _VAR(0);}
	j+=(c_file.attrib & _A_SUBDIR) ? 1 : 0;
	while(_findnext(lFile,&c_file)==0)
	{
		j+=(c_file.attrib & _A_SUBDIR) ? 1 : 0;
		i++;
	}
	return _VAR(j);
}

//list subfolders
DLLFUNC folder_list(STRING* wildcard,STRING* buf)
{
	struct _finddata_t c_file;
	long lFile=0;
	bool isdir=false;
	lFile=_findfirst( _CHR(wildcard), &c_file );
	if(lFile<0){return 0;}
	isdir=(c_file.attrib & _A_SUBDIR) ? true : false;
	if(isdir)
	{
		str_cat(buf,c_file.name);
		str_cat(buf,"\n");
	}
	while(_findnext(lFile,&c_file)==0)
	{
		isdir=(c_file.attrib & _A_SUBDIR) ? true : false;
		if(isdir)
		{
			str_cat(buf,c_file.name);
			str_cat(buf,"\n");
		}
	}
}

//rename a folder
DLLFUNC folder_rename(STRING* oldname,STRING* newname)
{
	int a = rename(_CHR(oldname),_CHR(newname));
	if(a==0){return _VAR(1);}
	return _VAR(0);
}

//read out creation/last-access/last-edit date of the file/folder
DLLFUNC file_date(STRING* filename,var funcmode)
{
	static STRING *buf = (STRING*)engine_getobj("foundfile");
	struct _finddata_t c_file;
	long lFile=0;
	lFile=_findfirst( _CHR(filename), &c_file );
	if(lFile<0){return _VAR(0);}
	
	if(_INT(funcmode)==0){str_cpy(buf,ctime( &( c_file.time_create )));}
	if(_INT(funcmode)==1){str_cpy(buf,ctime( &( c_file.time_access )));}
	if(_INT(funcmode)==2){str_cpy(buf,ctime( &( c_file.time_write )));}
}

//get the foldernames from a directory
DLLFUNC folder_get(STRING* wildcard, var number)
{
	static STRING *buf = (STRING*)engine_getobj("foundfile");
	struct _finddata_t c_file;
	long lFile=0;
	int stop = _INT(number);
	int i=1;
	bool isdir=false;
	lFile=_findfirst( _CHR(wildcard), &c_file );
	if(lFile<0){return _VAR(0);}
	isdir=(c_file.attrib & _A_SUBDIR) ? true : false;
	if((isdir)&&(stop==1))
	{
		str_cpy(buf,c_file.name);
	}
	while((_findnext(lFile,&c_file)==0)&&(stop!=i))
	{
		isdir=(c_file.attrib & _A_SUBDIR) ? true : false;
		if(isdir)
		{
			str_cpy(buf,c_file.name);
			i++;
		}
		
	}
	return _VAR(1);
}


compile it with latest engine sdk and it should work with lite-c. of courese you will need a new header.


3333333333