Ejemplo n.º 1
0
int ReadFile( char *folder )
{
	char str[FILENAMEMAX];
	FONTCHARACTER find_path[50];
	FONTCHARACTER find_name[50];
	FILE_INFO file_info;
	int find_h;
	int size, i;

	int iError=0;
	int iFirst=0;

	size = 0;
	FilePath( folder, find_path);

	//	Get File count	
	do
	{
	  if(iFirst==0) {
        iError=Bfile_FindFirst(find_path,&find_h,find_name,&file_info);
        iFirst=1;
      } 
	  else {
        iError=Bfile_FindNext(find_h,find_name,&file_info);
      }
	  if( iError == 0 && ( file_info.type == DT_DIRECTORY ||  IsCsvFile( find_name ) ) )
		++size ;
	}
	while (iError == 0);
	Bfile_FindClose(find_h);
	//	Get File name	
	files = (Files *)calloc(1,size*FILENAMEMAX);
	i = 0;
	iError=0;
	iFirst=0;
	do
	{
	  if(iFirst==0) {
        iError=Bfile_FindFirst(find_path,&find_h,find_name,&file_info);
        iFirst=1;
      } 
	  else {
        iError=Bfile_FindNext(find_h,find_name,&file_info);
      }
	  if( iError == 0 && ( file_info.type == DT_DIRECTORY ||  IsCsvFile( find_name ) ) ){
			FontToChar(find_name,str);
			strncpy( files[i].filename, str, FILENAMEMAX);
			files[i].filesize = (file_info.type == DT_DIRECTORY ? -1 : file_info.dsize);
			++i;
		}
	} while (iError == 0);

	Bfile_FindClose(find_h);
	return size;
}
Ejemplo n.º 2
0
int memory_find(char *adresse, char **files, int max)
{
  FONTCHARACTER *adr = memory_char2font(adresse);
  FONTCHARACTER found[30];
  FILE_INFO fileInfo;
  int searchHandle,i=1,j,x;

  if(x = Bfile_FindFirst(adr,&searchHandle,found,&fileInfo)) return 0;
  for(j=0;j<14 && *(found+j);j++) *(*files+j) = *(found+j);

  while(Bfile_FindNext(searchHandle,found,&fileInfo)==0 && i<max) {
    for(j=0;j<14 && *(found+j);j++) *(*(files+i)+j) = *(found+j);
    i++; }

  Bfile_FindClose(searchHandle);
  free(adr);
  return i;
}
Ejemplo n.º 3
0
///////////////////////////////////////////////////////////////
//							File List
///////////////////////////////////////////////////////////////
int SelectFiles3 (char * file_name)
// -1 no file , 1 complate ,0 cancel
{
	int key;
	char str[50]; //字符数组长度下标从0开始,共50个元素
	FONTCHARACTER find_path[50];   //获得路径
	FONTCHARACTER find_name[50];   //获得名字
	int find_h;
	int size = 0;
	int top = 0;
	int buttom = 0;
	int index,r,y;
	char *files;
	FILE_INFO file_info;
//	CharToFont("\\\\fls0\\ZDM\\*.zdm",find_path);
	sprintf(str,"%s\\*.zdm",szSrdDir3);
	CharToFonts3(str,find_path);
	if(Bfile_FindFirst (find_path,&find_h,find_name,&file_info)==0)  //函数搜索目录中文件的名称符合指定的文件名
	{
		int i=0,ret;
		BOOL bFindFirst=TRUE; //定义一个布尔型变量初始化为真(true),对于bool类型,值只要不是0就是为真,即true;当值为0时为假,即false;
		size ++;  //使用size之后再加一(先计算再操作)
		while(Bfile_FindNext(find_h,find_name,&file_info)==0) //Bfile_FindNext 函数使用搜索处理定位匹配一个给定名称的文件名称。
		size++;
		Bfile_FindClose(find_h);  //Bfile_FindClose 关闭搜索指定处理函数
		files = (char*)malloc(size*13);
		index = 0;
		for(;;)
		{
			if(bFindFirst)  //if 值为真
				ret=Bfile_FindFirst (find_path,&find_h,find_name,&file_info);
			else 
				ret=Bfile_FindNext(find_h,find_name,&file_info);
			if(ret!=0)  //if 
				break;
			strncpy((files+13*i),FontToChars3(find_name,str),13);
			if(strcmp((files+13*i),setup_data.zdmroute_name)==0) //文件选中后,现在记忆位置
			index=i; 
			i++;
			bFindFirst=FALSE;  //令值为假 即=0
		}
		Bfile_FindClose(find_h);  //Bfile_FindClose 关闭搜索指定处理函数
		r = 1;
		top = 0;
		buttom = 4;
		while(1)   
		{
			if (r)
			{
				Bdisp_AllClr_VRAM();
				//PopUpWin(6);
				DispStr(20,8,"纵断面文件: ");
				if (buttom-top>3)buttom = top + 3;
				if(top>index)
				{
					top = index;
					buttom = index + 3;
				}
				if (index>buttom)
				{
					buttom = index;
					top = buttom - 3;
				}
				if(buttom>size - 1)buttom = size - 1;
				if(top<0) top = 0;
				for (i=top;i<=buttom;++i)
				{
					//sprintf(str,"%13.13s",(files+13*i));
					//y=2+(i-top)*13;   //顶部文件位置
					//SetMyFont(&stHz12x12,&stAsc6x12);
					//DispStr(18,y,str); //str[]是字符串
					//if(index==i)
					//Bdisp_AreaReverseVRAM(15,y,20+13*6,y+11);
				    PrintfXY(20,22+(i-top)*8,index==i,"%13.13s",(files+13*i));
				}
				PrintXY(100,22,top>0?"\xE6\x92":" ",0);
				PrintXY(100,46,buttom<size-1?"\xE6\x93":" ",0);
				r = 0;
			}
			GetKey(&key);
			if (key==KEY_CTRL_UP) 	{if(--index<0) index = size - 1;r = 1;}
			if (key==KEY_CTRL_DOWN)	{if(++index>size - 1) index = 0;r = 1;}
			if (key==KEY_CTRL_EXE)
			{
				strcpy(file_name,(files+13*index));
				free (files);
				return 1;
			}
			if (key==KEY_CTRL_EXIT)
			{
				free (files);
				return 0;
			}
		}
	}
	else
		return -1;
	
}