示例#1
0
void GBomb::PlaceFlames() {  
  GFlame* flame = new GFlame();
  flame->X = X;
  flame->Y = Y;
  GFlame::FlameList.push_back(flame);
  flame->CheckBombs();
  flame->CheckBombers();
  //flame->CheckPowerups();
  int centX = X;
  int centY = Y;

  if (! (ChainedFrom & FLAME_CHAIN_UP))
    CheckDir(centX, centY, FLAME_DOWN);
   
  if (! (ChainedFrom & FLAME_CHAIN_RIGHT))
    CheckDir(centX, centY, FLAME_LEFT);
   
  if (! (ChainedFrom & FLAME_CHAIN_DOWN))
    CheckDir(centX, centY, FLAME_UP);

  if (! (ChainedFrom & FLAME_CHAIN_LEFT))
    CheckDir(centX, centY, FLAME_RIGHT);

 
}
示例#2
0
文件: main.cpp 项目: aolingwen/TFDS
void SaveImage(vector<SProcessResult> results)
{
	string strSaveImagePath = CTFDSConfigValue::GetInstance()->m_strSaveImagePath;
	CheckDir(strSaveImagePath);
	for (int i = 0; i != results.size(); ++i)
	{
		CheckDir(strSaveImagePath+"\\"+results[i].m_strFoloder_name);
		string strNewImagePath = strSaveImagePath+"\\"+results[i].m_strImage_name;
		if (strNewImagePath == string(strSaveImagePath+"\\"))
		{
			continue;
		}
		imwrite(strNewImagePath, results[i].m_matImage);
	}
}
void fs_fsPathCombo_changed( GtkEditable * editable,gpointer user_data )
{
 const unsigned char * str;

 str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
 if ( chdir( str ) != -1 ) CheckDir( fsFNameList,get_current_dir_name() );
}
void fs_Up_released( GtkButton * button,gpointer user_data )
{
 chdir( ".." );
 fsSelectedFile=fsThatDir;
 CheckDir( fsFNameList,get_current_dir_name() );
 gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
 return;
}
示例#5
0
int
CheckOrCreate (const char *what)
{
	mode_t        perms = 0755;
	int           res = 0;

	if (*what == '~' && *(what + 1) == '/')
	{
		char         *checkdir = put_file_home (what);

		if (CheckDir (checkdir) != 0)
			res = MakeASDir (checkdir, perms);
		free (checkdir);
	} else if (CheckDir (what) != 0)
		res = MakeASDir (what, perms);

	return res;
}
void fs_Ok_released( GtkButton * button,gpointer user_data )
{
 GList         * item;
 int             i = 1;
 struct stat     fs;

 stat( fsSelectedFile,&fs );
 if(  S_ISDIR(fs.st_mode ) )
  {
   chdir( fsSelectedFile );
   fsSelectedFile=fsThatDir;
   CheckDir( fsFNameList,get_current_dir_name() );
   gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name() );
   return;
  }

        fsSelectedDirectory=(unsigned char *)get_current_dir_name();
 switch ( fsType )
  {
   case fsVideoSelector:
          guiSetDF( guiIntfStruct.Filename,fsSelectedDirectory,fsSelectedFile );
          guiIntfStruct.StreamType=STREAMTYPE_FILE;
          guiIntfStruct.FilenameChanged=1; sub_fps=0;
	  gfree( (void **)&guiIntfStruct.AudioFile );
	  gfree( (void **)&guiIntfStruct.Subtitlename );
          fs_PersistantHistory( fsSelectedDirectory );      //totem, write into history
          break;
   case fsSubtitleSelector:
          guiSetDF( guiIntfStruct.Subtitlename,fsSelectedDirectory,fsSelectedFile );
	  guiLoadSubtitle( guiIntfStruct.Subtitlename );
          break;
   case fsOtherSelector:
          guiSetDF( guiIntfStruct.Othername,fsSelectedDirectory,fsSelectedFile );
          break;
   case fsAudioSelector:
          guiSetDF( guiIntfStruct.AudioFile,fsSelectedDirectory,fsSelectedFile );
          break;
   case fsFontSelector:
          guiSetDF( font_name,fsSelectedDirectory,fsSelectedFile );
	  guiLoadFont();
	  if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name );
	  break;
  }

 HideFileSelect();

 item=fsTopList_items;
 while( item )
  {
   if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0;
   item=item->next;
  }
 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name() );
 if ( mplMainAutoPlay ) { mplMainAutoPlay=0; mplEventHandling( evPlay,0 ); }
  else guiGetEvent( guiCEvent,guiSetStop );
}
示例#7
0
static void fs_Ok_released( GtkButton * button, gpointer user_data )
{
 GList         * item;
 int             i = 1;
 struct stat     fs;

 stat( fsSelectedFile,&fs );
 if(  S_ISDIR(fs.st_mode ) )
  {
   chdir( fsSelectedFile );
   fsSelectedFile=fsThatDir;
   CheckDir( fsFNameList );
   gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() );
   gtk_widget_grab_focus( fsFNameList );
   return;
  }

        fsSelectedDirectory=(unsigned char *)get_current_dir_name();
 switch ( fsType )
  {
   case fsVideoSelector:
          uiSetFileName( fsSelectedDirectory,fsSelectedFile,STREAMTYPE_FILE );
          guiInfo.NewPlay=GUI_FILE_NEW; sub_fps=0;
          fs_PersistantHistory( get_current_dir_name_utf8() );      //totem, write into history
          break;
   case fsSubtitleSelector:
          setddup( &guiInfo.SubtitleFilename,fsSelectedDirectory,fsSelectedFile );
	  mplayerLoadSubtitle( guiInfo.SubtitleFilename );
          break;
/*   case fsOtherSelector:
          setddup( &guiInfo.Othername,fsSelectedDirectory,fsSelectedFile );
          break;*/
   case fsAudioSelector:
          setddup( &guiInfo.AudioFilename,fsSelectedDirectory,fsSelectedFile );
          break;
   case fsFontSelector:
          setddup( &font_name,fsSelectedDirectory,fsSelectedFile );
	  mplayerLoadFont();
	  if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name );
	  break;
  }

 HideFileSelect();

 item=fsTopList_items;
 while( item )
  {
   if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0;
   item=item->next;
  }
 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name_utf8() );
 if ( uiMainAutoPlay ) { uiMainAutoPlay=0; uiEventHandling( evPlay,0 ); }
  else gui( GUI_SET_STATE,(void *) GUI_STOP );
}
示例#8
0
static void fs_fsPathCombo_changed( GtkEditable * editable,
                                    gpointer user_data )
{
 const unsigned char * str;
 gchar * dirname;

 str=gtk_entry_get_text( GTK_ENTRY( user_data ) );
 dirname = g_filename_from_utf8( str, -1, NULL, NULL, NULL );
 if ( chdir( dirname ? (const unsigned char *)dirname : str ) != -1 ) CheckDir( fsFNameList );
 g_free( dirname );
}
示例#9
0
void
load_feel_menu( ASFeel *feel, char *location )
{
    char *fullfilename ;
    if( location && feel )
    {
        fullfilename = put_file_home( location );
#if 0
        if ( CheckDir (fullfilename) == 0 )
            dir2menu_data( fullfilename, &(feel->menus_list));
        else if ( CheckFile (fullfilename) == 0 )
            file2menu_data( fullfilename, &(feel->menus_list));
        else
            show_error("unable to locate menu at location [%s].", fullfilename);
#endif
        free( fullfilename );
    }
}
示例#10
0
void CFileLog::Init()
{
	char szAllPath[128] = {0};
	//配置文件读取日志文件存放路径 TODO:
	memset(m_szFilePath, 0, sizeof(m_szFilePath));
	auto strLogDir = ConfigIni::ReadStr("FILE", "FILENAME");
	if (strLogDir == "")
	{
		std::cout << "read FILENAME failed" << std::endl;
		exit(-1);
	}
	strncpy(m_szFilePath, strLogDir.c_str(), sizeof(m_szFilePath)-1);
	//获取当前日期作为路径
	m_lCurTime = GetCurTime();
	snprintf(szAllPath, sizeof(szAllPath)-1, "%s/%ld", m_szFilePath, m_lCurTime );

	CheckDir(szAllPath);
	ReOpen();
}
示例#11
0
bool ShareMemory::OpenFileMap()
{
#ifdef WIN32
	return false;
#else
	CheckDir( m_mapFilePath.c_str() );
	string strFile = m_mapFilePath + "/" + m_shareName;
	CheckFile( strFile.c_str() );
	int fd;
	fd = open(strFile.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
	if ( -1 == fd ) 
	{
		m_lastError = "open file error:" + strFile;
		return false;
	}
	struct stat sb;
	fstat(fd,&sb);
	if ( sb.st_size < (long)m_dwSize )
	{
		lseek(fd, m_dwSize, SEEK_SET);
		write(fd, "\0", 1);
		lseek(fd, 0, SEEK_SET);
		fstat(fd,&sb);
		m_dwSize = sb.st_size;
	}
	
	m_lpFileMapBuffer = mmap(0,
		m_dwSize,
		PROT_WRITE|PROT_READ, //ÔÊÐíдÈë
		MAP_SHARED,//дÈëÄÚÈݱ»Á¢¼´Ð´Èëµ½Îļþ
		fd,
		0);
	close(fd);
	if ( NULL == m_lpFileMapBuffer ) 
	{
		m_lastError = "create file map error";
		return false;
	}
	return true;
#endif 
}
int procedureFiles()
{
    _finddata_t fileDir;
    std::string baseDir = "F:\\照片\\";
    std::string dir = "F:\\照片\\*.JPG";
    long lfDir = -1l;

    if ((lfDir = _findfirst(dir.c_str(), &fileDir)) == -1l)
    {
        std::cout << "No file is found" << std::endl;
    }
    else 
    {
        std::cout << "file list:" << std::endl;
        do
        {
            
            if (strcmp(fileDir.name, ".") == 0|| strcmp(fileDir.name, "..") == 0)
            {
                continue;
            }
            std::cout << fileDir.name << std::endl;
            CFileStatus status = { 0 };
            std::string curFileDir = baseDir + fileDir.name;
            CFile::GetStatus(curFileDir.c_str(), status);
            CString createTime = status.m_ctime.Format("%Y-%m-%d");
            char createDate[100];
            strcpy_s(createDate, createTime);
            std::string curFolderDir = baseDir + createDate;
            CheckDir(baseDir.c_str(), curFolderDir.c_str());
            std::string oldPath = baseDir + fileDir.name;
            std::string newPath = curFolderDir + "\\" + fileDir.name;
            std::string cmd = "move " + oldPath + " " + newPath;
            system(cmd.c_str());
        }while(_findnext(lfDir, &fileDir) == 0);
    }
    _findclose(lfDir);

    return 0;
}
示例#13
0
Bool
add_KDE_colorscheme( const char *new_cs_file ) 
{
	Bool success = False; 
#define KDE_CSRC_PATH  		"$KDEHOME/share/apps/kdisplay/color-schemes/"
	
	if( new_cs_file ) 
	{	
		int i = 1;
		char *dst_path ;
		char *dst_full_fname ; 
		char *fname  = NULL ; 

		parse_file_name(new_cs_file, NULL, &fname );
		dst_path = copy_replace_envvar( KDE_CSRC_PATH );
		
		while( dst_path[i] != '\0' ) 
		{	
			if( dst_path[i] == '/' ) 
			{
				char t = dst_path[i];
				dst_path[i] = '\0' ; 
				if (CheckDir (dst_path) != 0)
					mkdir (dst_path, 0755);
				dst_path[i] = t ;
			}
			++i;
		}			   

		dst_full_fname = safemalloc( i+strlen(fname)+1 );
		sprintf( dst_full_fname, "%s%s", dst_path, fname );
		success = (CopyFile( new_cs_file, dst_full_fname )==0);

		free( dst_full_fname );
		free( dst_path );
		free( fname );
	}

	return success;
}
示例#14
0
static void fs_fsFilterCombo_changed( GtkEditable * editable,
                                      gpointer user_data )
{
 const char * str;
 int    i;

 str=gtk_entry_get_text( GTK_ENTRY(user_data ) );

 switch ( fsType )
  {
   case fsVideoSelector:
          for( i=0;fsVideoFilterNames[i][0];i++ )
           if( !strcmp( str,fsVideoFilterNames[i][0] ) )
            { fsFilter=fsVideoFilterNames[i][1]; fsLastVideoFilterSelected = i;	break; }
          break;
   case fsSubtitleSelector:
          for( i=0;fsSubtitleFilterNames[i][0];i++ )
           if( !strcmp( str,fsSubtitleFilterNames[i][0] ) )
            { fsFilter=fsSubtitleFilterNames[i][1]; fsLastSubtitleFilterSelected = i; break; }
          break;
   case fsOtherSelector:
          for( i=0;fsOtherFilterNames[i][0];i++ )
           if( !strcmp( str,fsOtherFilterNames[i][0] ) )
            { fsFilter=fsOtherFilterNames[i][1]; break; }
          break;
   case fsAudioSelector:
          for( i=0;fsAudioFileNames[i][0];i++ )
           if( !strcmp( str,fsAudioFileNames[i][0] ) )
            { fsFilter=fsAudioFileNames[i][1]; fsLastAudioFilterSelected = i; break; }
	  break;
   case fsFontSelector:
          for( i=0;fsFontFileNames[i][0];i++ )
	    if( !strcmp( str,fsFontFileNames[i][0] ) )
	     { fsFilter=fsFontFileNames[i][1]; fsLastFontFilterSelected = i; break; }
	  break;
   default: return;
  }
 CheckDir( fsFNameList );
}
示例#15
0
int
main(int argc, char **argv)
{
    DInit(600);
    argc--;
    argv++;

    if (argc == 0)
	Usage();

    switch ((*argv++)[1]) {
    case 'l':
	ListDir(*argv);
	break;
    case 'c':
	CheckDir(*argv);
	break;
    case 's':
	SalvageDir(*argv, argv[1]);
	break;
    case 'f':
	CRTest(*argv, argv[1], atoi(argv[2]));
	break;
    case 'd':
	DelTest(*argv, argv[1]);
	break;
    case 'r':
	LookupDir(*argv, argv[1]);
	break;
    case 'a':
	AddEntry(*argv, argv[1]);
	break;
    default:
	Usage();
    }
    exit(0);
}
示例#16
0
文件: ai_nodes.c 项目: mylemans/vrxcl
//==========================================
// AI_LoadPLKFile
// load nodes and plinks from file
//==========================================
qboolean AI_LoadPLKFile( char *mapname )
{
	FILE *pIn;
	int			i;
	char		filename[MAX_OSPATH];
	int			version;

	CheckDir(va("%s/%s", game_path->string, AI_NODES_FOLDER));

	Com_sprintf (filename, sizeof(filename), "%s/%s/%s.%s", game_path->string, AI_NODES_FOLDER, mapname, NAV_FILE_EXTENSION);

	pIn = fopen( filename, "rb" );
	if( pIn  == NULL )
		return false; 

	// check version
	fread( &version, sizeof(int), 1, pIn);

	if( version != NAV_FILE_VERSION )
	{
		fclose(pIn);
		return false;
	}
	
	fread( &nav.num_nodes, sizeof(int), 1, pIn);

	for (i=0; i<nav.num_nodes; i++)
		fread( &nodes[i], sizeof(nav_node_t), 1, pIn );
	
	for(i=0; i<nav.num_nodes;i++)
		fread( &pLinks[i], sizeof(nav_plink_t), 1, pIn );

	fclose(pIn);

	return true;
}
示例#17
0
// #################################################################
//
void COMB::ReadInputFile(TextParser* tpCntl)
{
    string str;
    string label,label_base,label_leaf;

    // node数の取得
    int nnode=0;
    label_base = "/CombData";
    if ( tpCntl->chkNode(label_base) )  //nodeがあれば
    {
        nnode = tpCntl->countLabels(label_base);
    }

    // dfi_nameの取得
    dfi_name.clear();
    label_base = "/CombData";
    for (int i=0; i<nnode; i++) {

        if ( !(tpCntl->getNodeStr(label_base, i+1, str)) )
        {
            printf("\tParsing error : No Elem name\n");
            Exit(0);
        }
        if( strcasecmp(str.substr(0,4).c_str(), "list") ) continue;
        label=label_base+"/"+str;

        if ( !(tpCntl->getInspectedValue(label, str )) ) {
            printf("\tParsing error : fail to get '%s'\n", label.c_str());
            Exit(0);
        }

        dfi_name.push_back(str.c_str());

    }

#if 0
    cout << "dfi_name.size() = " << dfi_name.size() << endl;
    vector<string>::const_iterator it;
    for (it = dfi_name.begin(); it != dfi_name.end(); it++) {
        cout << "name = " << (*it).c_str() << endl;
    }
#endif


    //出力ディレクトリの指定 ---> 実行オプションよりこちらが優先される
    label = "/CombData/OutputDir";
    if ( (tpCntl->getInspectedValue(label, str )) )
    {
        out_dirname=str;
        LOG_OUT_ fprintf(fplog,"\tReset Output Directory '%s'\n", out_dirname.c_str());
        STD_OUT_ printf("\tReset Output Directory '%s'\n", out_dirname.c_str());
        CheckDir(out_dirname);
        if( out_dirname.size() != 0 ) out_dirname=out_dirname+"/";
    }


    //入力ディレクトリの指定
    label = "/CombData/InputDir";
    if ( (tpCntl->getInspectedValue(label, str )) )
    {
        in_dirname=str;
        LOG_OUT_ fprintf(fplog,"\tReset Input Directory '%s'\n", in_dirname.c_str());
        STD_OUT_ printf("\tReset Input Directory '%s'\n", in_dirname.c_str());
        CheckDir(in_dirname);
        if( in_dirname.size() != 0 ) in_dirname=in_dirname+"/";
    }


    //並列実行時のSTAGINGのON/OFF
    label = "/CombData/Staging";
    if ( !(tpCntl->getInspectedValue(label, str )) )
    {
        staging = OFF;
    }
    else
    {
        if     ( !strcasecmp(str.c_str(), "on") )  staging = ON;
        else if( !strcasecmp(str.c_str(), "off") ) staging = OFF;
        else
        {
            Hostonly_ stamped_printf("\tInvalid keyword is described for '%s'\n", label.c_str());
            Exit(0);
        }
    }


    //出力の単精度or倍精度指定 ---> PLOT3Dの場合は、optionに記述があればそちらを優先
    label = "/CombData/OutputRealType";
    if ( !(tpCntl->getInspectedValue(label, str )) )
    {
        output_real_type = OUTPUT_REAL_UNKNOWN;
    }
    if     ( !strcasecmp(str.c_str(), "float" ) )  output_real_type = OUTPUT_FLOAT;
    else if( !strcasecmp(str.c_str(), "double" ) ) output_real_type = OUTPUT_DOUBLE;
    else
    {
        printf("\tInvalid keyword is described for '%s'\n", label.c_str());
        Exit(0);
    }

    // 連結ファイルの出力フォーマット
    label = "/CombData/OutFormat";
    if ( !(tpCntl->getInspectedValue(label, str )) )
    {
        printf("\tParsing error : fail to get '%s'\n", label.c_str());
        Exit(0);
    }
    if     ( !strcasecmp(str.c_str(), "sph" ) )    out_format = OUTFORMAT_IS_SPH;
    else if( !strcasecmp(str.c_str(), "plot3d" ) ) out_format = OUTFORMAT_IS_PLOT3D;
    else if( !strcasecmp(str.c_str(), "avs" ) ) out_format = OUTFORMAT_IS_AVS;
    else
    {
        printf("\tInvalid keyword is described for  '%s'\n", label.c_str());
        Exit(0);
    }

    // PLOT3Dオプションの読み込み
    // PLOT3Dfunctions_20131005 if( out_format == OUTFORMAT_IS_PLOT3D ) get_PLOT3D(tpCntl);

    // AVSオプションの読み込み
    if( out_format == OUTFORMAT_IS_AVS ) get_AVSoptions(tpCntl);

}
示例#18
0
void
check_AfterStep_dirtree ( char * ashome, Bool create_non_conf )
{
	char         *fullfilename;
	/* Create missing directories & put there defaults */
	if (CheckDir (ashome) != 0)
	{
		CheckOrCreate (ashome);

#if defined(DO_SEND_POSTCARD) /*&& defined(HAVE_POPEN) */
		/* send some info to sasha @ aftercode.net */
		{
			FILE *p;
			char *filename = make_file_name(ashome, ".postcard");
			/*p = popen ("mail -s \"AfterStep installation info\" [email protected]", "w");*/
			p = fopen( filename, "wt" );
			free(filename);
			if (p)
			{
				fprintf( p, "AfterStep_Version=\"%s\";\n", VERSION );
				fprintf( p, "CanonicalBuild=\"%s\";\n", CANONICAL_BUILD );
				fprintf( p, "CanonicalOS=\"%s\";\n", CANONICAL_BUILD_OS );
				fprintf( p, "CanonicalCPU=\"%s\";\n", CANONICAL_BUILD_CPU );
				fprintf( p, "CanonicalVendor=\"%s\";\n", CANONICAL_BUILD_VENDOR );
				if( dpy )
				{
					fprintf (p, "X_DefaultScreenNumber=%d;\n", DefaultScreen (dpy));
					fprintf (p, "X_NumberOfScreens=%d;\n", ScreenCount (dpy));
					fprintf (p, "X_Display=\"%s\";\n", DisplayString (dpy));
					fprintf (p, "X_ProtocolVersion=%d.%d;\n", ProtocolVersion (dpy), ProtocolRevision (dpy));
					fprintf (p, "X_Vendor=\"%s\";\n", ServerVendor (dpy));
					fprintf (p, "X_VendorRelease=%d;\n", VendorRelease (dpy));
					if (strstr(ServerVendor (dpy), "XFree86"))
					{
						int vendrel = VendorRelease(dpy);
						fprintf(p, "X_XFree86Version=");
						if (vendrel < 336)
						{
							fprintf(p, "%d.%d.%d", vendrel / 100, (vendrel / 10) % 10, vendrel       % 10);
						} else if (vendrel < 3900)
						{
							fprintf(p, "%d.%d", vendrel / 1000,  (vendrel /  100) % 10);
							if (((vendrel / 10) % 10) || (vendrel % 10))
							{
								fprintf(p, ".%d", (vendrel / 10) % 10);
								if (vendrel % 10)
									fprintf(p, ".%d", vendrel % 10);
							}
						} else if (vendrel < 40000000)
						{
							fprintf(p, "%d.%d", vendrel/1000,  (vendrel/10) % 10);
							if (vendrel % 10)
								fprintf(p, ".%d", vendrel % 10);
						} else
						{
							fprintf(p, "%d.%d.%d", vendrel/10000000,(vendrel/100000)%100, (vendrel/1000)%100);
							if (vendrel % 1000)
								fprintf(p, ".%d", vendrel % 1000);
						}
						fprintf(p, ";\n");
					}
					if( ASDefaultScrWidth > 0 )
					{
						fprintf( p, "AS_Screen=%ld;\n", ASDefaultScr->screen );
						fprintf( p, "AS_RootGeometry=%dx%d;\n", ASDefaultScrWidth, ASDefaultScrHeight );
					}
					if( ASDefaultVisual )
					{
						fprintf( p, "AS_Visual=0x%lx;\n", ASDefaultVisual->visual_info.visualid );
						fprintf( p, "AS_Colordepth=%d;\n", ASDefaultVisual->visual_info.depth );
						fprintf( p, "AS_RedMask=0x%lX;\n", ASDefaultVisual->visual_info.red_mask );
						fprintf( p, "AS_GreenMask=0x%lX;\n", ASDefaultVisual->visual_info.green_mask );
						fprintf( p, "AS_BlueMask=0x%lX;\n", ASDefaultVisual->visual_info.blue_mask );
						fprintf( p, "AS_ByteOrdering=%s;\n", (ImageByteOrder(ASDefaultVisual->dpy)==MSBFirst)?"MSBFirst":"LSBFirst" );
					}
				}
				fclose(p);
				/*pclose (p);*/
			/*p = popen ("mail -s \"AfterStep installation info\" [email protected]", "w");*/
			}
		}
#endif
	}
	fullfilename = make_file_name (ashome, AFTER_SAVE);
	CheckOrCreateFile (fullfilename);
	free( fullfilename );

#if 0
	fullfilename = make_file_name (ashome, THEME_FILE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, LOOK_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, FEEL_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, THEME_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, COLORSCHEME_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, BACK_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );
#endif
	fullfilename = make_file_name (ashome, DESKTOP_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, ICON_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, FONT_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, TILE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );

	fullfilename = make_file_name (ashome, WEBCACHE_DIR);
	CheckOrCreate(fullfilename);
	free( fullfilename );
	
	if( create_non_conf )
	{
		char *postcard_fname ;
		FILE *f ;
		fullfilename = make_file_name (ashome, AFTER_NONCF);
		/* legacy non-configurable dir: */
		CheckOrCreate(fullfilename);
		postcard_fname = make_file_name( fullfilename, "send_postcard.sh" );
		free( fullfilename );
		
		f = fopen( postcard_fname, "wt" );
		if( f ) 
		{
			fprintf( f, "#!/bin/sh\n\n" );
			fprintf( f, "if [ -r %s/.postcard ] \nthen echo -n \nelse rm %s \nexit\nfi\n", ashome, postcard_fname );
			fprintf( f, "x-terminal-emulator -e \"%s/tools/postcard.sh\"\n", AFTER_SHAREDIR );
			fprintf( f, "if [ -r %s/.postcard ] \nthen echo -n \nelse rm %s \nfi\n", ashome, postcard_fname );
			fclose( f );
		}
		chmod (postcard_fname, 0700);
		free(postcard_fname);
	}

	char *cachefilename = make_file_name(ashome, THUMBNAILS_DIR);
	CheckOrCreate(cachefilename);
	extern void set_asimage_thumbnails_cache_dir(const char*);
	set_asimage_thumbnails_cache_dir(cachefilename);
	free( cachefilename );
}
示例#19
0
FResourceFile *FResourceFile::OpenDirectory(const char *filename, bool quiet)
{
	return CheckDir(filename, NULL, quiet);
}
示例#20
0
void 
check_syntax_source( const char *source_dir, SyntaxDef *syntax, Bool module )
{
	int i ;
	char *syntax_dir = NULL ;
	char *obsolete_dir ;
	struct direntry  **list = NULL;
	int list_len ;

	if( syntax )
	{	
		if( get_hash_item( ProcessedSyntaxes, AS_HASHABLE(syntax), NULL ) == ASH_Success )
			return ;

		if( syntax->doc_path != NULL && syntax->doc_path[0] != '\0' )
			syntax_dir = make_file_name (source_dir, syntax->doc_path); 
	}
	if( syntax_dir == NULL ) 
		syntax_dir = mystrdup( source_dir );
	
	obsolete_dir = make_file_name (syntax_dir, "obsolete" );
	
	if( CheckDir(syntax_dir) != 0 )
		if( !make_doc_dir( syntax_dir ) ) 
		{
			free( syntax_dir );
			return;
		}

	if( syntax ) 
	{	
		add_hash_item( ProcessedSyntaxes, AS_HASHABLE(syntax), NULL );   

		/* pass one: lets see which of the existing files have no related options : */
		list_len = my_scandir ((char*)syntax_dir, &list, ignore_dots, NULL);
		for (i = 0; i < list_len; i++)
		{	
			int k ;
			if (!S_ISDIR (list[i]->d_mode))
			{	
				char *name = list[i]->d_name ;
				show_progress( "checking \"%s\" ... ", name );
				if( name[0] != '_' ) 
				{	
					for (k = 0; syntax->terms[k].keyword; k++)
						if( mystrcasecmp(name, syntax->terms[k].keyword ) == 0 ) 
							break;
					if( syntax->terms[k].keyword == NULL || get_flags( syntax->terms[k].flags, TF_OBSOLETE) ) 
					{
						/* obsolete option - move it away */
						char *obsolete_fname = make_file_name (obsolete_dir, name );
						char *fname = make_file_name (syntax_dir, name );
						Bool no_dir = False ;
						if( CheckDir(obsolete_dir) != 0 )
							no_dir = !make_doc_dir( obsolete_dir ) ;
						if( !no_dir )
						{
							copy_file (fname, obsolete_fname);
							show_progress( "Option \"%s\" is obsolete - moving away!", name );
							unlink(fname);
						}
						free( fname );
						free( obsolete_fname ); 
					}	 
				}
			}		
			free( list[i] );
		}
		if( list )
			free (list);
		/* pass two: lets see which options are missing : */
		for (i = 0; syntax->terms[i].keyword; i++)
		{	
			if( !get_flags( syntax->terms[i].flags, TF_OBSOLETE) )
			{	
				SyntaxDef *sub_syntax = syntax->terms[i].sub_syntax ; 
				if( sub_syntax == pPopupFuncSyntax ) 
					sub_syntax = pFuncSyntax ;
				if (sub_syntax)
					check_syntax_source( source_dir, sub_syntax, False );
				if( isalnum( syntax->terms[i].keyword[0] ) )					
					check_option_source( syntax_dir, syntax->terms[i].keyword, sub_syntax, module?syntax->doc_path:NULL ) ;
			}
		}
		for (i = module?0:1; StandardSourceEntries[i] != NULL ; ++i)
			check_option_source( syntax_dir, StandardSourceEntries[i], NULL, module?syntax->doc_path:NULL ) ;
		if( module ) 
		{
			check_option_source( syntax_dir, BaseOptionsEntry, NULL, syntax->doc_path ) ;
			check_option_source( syntax_dir, MyStylesOptionsEntry, NULL, syntax->doc_path ) ;
		}	 
	}else
		generate_main_source( syntax_dir );

	free( obsolete_dir );
	free( syntax_dir );
}	 
void CDlgWnd::OnOpen()
{
    // Get the text and check whether it is a valid directory
    CString ss;
    CEdit *pEdit = (CEdit *)GetDlgItem(IDC_DIR);
    ASSERT(pEdit != NULL);
    pEdit->GetWindowText(ss);
    int len = ss.GetLength();

    if (len == 2 && ss[0] == '\\' && ss[1] == '\\')
    {
        AfxMessageBox(ss + _T("\nThis is not a valid folder."));
        pEdit->SetFocus();
        return;
    }
    else if (len == 0 || len == 1 && ss[0] == '\\')
    {
        // Current directory or root of the current drive (therefore must be valid)
        ;
    }
    else if ((len == 2 && ss[1] == ':') ||
             (len == 3 && ss[1] == ':' && ss[2] == '\\') )
    {
        _TCHAR rootdir[4] = _T("?:\\");
        rootdir[0] = ss[0];

        if (GetDriveType(rootdir) <= DRIVE_NO_ROOT_DIR)
        {
            AfxMessageBox(ss + _T("\nThe drive is invalid."));
            pEdit->SetFocus();
            return;
        }
    }
    else
    {
        // Check that it's a valid directory
        if (ss[len-1] == '\\')
            ss = ss.Left(--len);
        DWORD attr = GetFileAttributes(ss);
        if (attr == 0xFFFFFFFF)
        {
            const char *ss2;

            // Directory not found but maybe it's an invalid drive
            _TCHAR rootdir[4] = _T("?:\\");
            rootdir[0] = ss[0];

            if (len > 1 && ss[1] == ':' && GetDriveType(rootdir) <= DRIVE_NO_ROOT_DIR)
            {
                AfxMessageBox(ss + _T("\nThe drive is invalid."));
                pEdit->SetFocus();
                return;
            }
            else if (len >= 2 && ss[0] == '\\' && ss[1] == '\\' && 
                     ( (ss2 = strchr((const char *)ss+2, '\\')) == NULL || strchr(ss2+1, '\\') == NULL) )
            {
                AfxMessageBox(ss + _T("\nThis is not a valid folder."));
                pEdit->SetFocus();
                return;
            }
            else
            {
                // Appears to be a valid drive (or relative path)
                CString mess(ss);
                mess += _T("\nThis folder does not exist.\n\n"
                      "Do you want to create it?");
                if (AfxMessageBox(mess, MB_YESNO) == IDYES)
                {
                    // MakeSureDirectoryPathExists is not part of Windows but is
                    // in the IMAGHLP.DLL which is always present.  This call
                    // requires linking with IMAGHLP.LIB.
                    
					//if(0)
					if (!MakeSureDirectoryPathExists(ss + _T("\\")))
                    {
                        switch (GetDriveType(rootdir))
                        {
                        case DRIVE_CDROM:
                            AfxMessageBox(_T("You cannot create this folder\n"
                                          "as the CD ROM medium is read-only."));
                            break;
                        case DRIVE_REMOVABLE:
                            AfxMessageBox(_T("You cannot create this folder.\n"
                                          "The medium may be write-protected."));
                            break;
                        case DRIVE_REMOTE:
                            AfxMessageBox(_T("You do not have permission to create\n"
                                          "this folder on the network."));
                            break;
                        default:
                            AfxMessageBox(_T("You do not have permission\n"
                                          "to create this folder."));
                            break;
                        }
                        pEdit->SetFocus();
                        return;         // Directory could not be created
                    }
                    // directory was created, so continue
                }
                else
                {
                    pEdit->SetFocus();
                    return;             // User did not want to create directory
                }
            }
        }
        else if ((attr & FILE_ATTRIBUTE_DIRECTORY) == 0)
        {
            AfxMessageBox(ss + _T("\nThis is a file not a directory."));
            pEdit->SetFocus();
            return;
        }
    }

    // We have now selected a directory and will return from the dialog
    CheckDir(ss);

    ::EndDialog(m_hWnd, IDOK);
}
示例#22
0
void fs_fsFilterCombo_activate( GtkEditable * editable,gpointer user_data )
{
 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) );
 CheckDir( fsFNameList,get_current_dir_name() );
}
示例#23
0
static void fs_Ok_released( GtkButton * button, gpointer user_data )
{
 GList         * item;
 int             i = 1, l;
 struct stat     fs;
 gchar         * selected;

 if( ( stat( fsSelectedFile,&fs ) == 0 ) && S_ISDIR( fs.st_mode ) )
  {
   if ( chdir( fsSelectedFile ) != 0 ) return;
   fsSelectedFile=fsThatDir;
   CheckDir( fsFNameList );
   gtk_entry_set_text( GTK_ENTRY( fsPathCombo ),(unsigned char *)get_current_dir_name_utf8() );
   gtk_widget_grab_focus( fsFNameList );
   return;
  }

        fsSelectedDirectory=(unsigned char *)get_current_dir_name();
 switch ( fsType )
  {
   case fsVideoSelector:
          for (l = 0; fsVideoFilterNames[l][0]; l++)
            if (strcmp(fsVideoFilterNames[l][0], MSGTR_Filter_Playlists) == 0) break;
          uiSetFile( fsSelectedDirectory,fsSelectedFile, fsLastVideoFilterSelected == l ? STREAMTYPE_PLAYLIST : STREAMTYPE_FILE );
          selected = g_strconcat(fsSelectedDirectory, "/", fsSelectedFile, NULL);
          if (selected)
          {
            listMgr(PLAYLIST_DELETE, 0);
            add_to_gui_playlist(selected, PLAYLIST_ITEM_APPEND);
            g_free(selected);
          }
          guiInfo.NewPlay=GUI_FILE_NEW; sub_fps=0;
          fs_PersistantHistory( get_current_dir_name_utf8() );      //totem, write into history
          break;
   case fsSubtitleSelector:
          setddup( &guiInfo.SubtitleFilename,fsSelectedDirectory,fsSelectedFile );
	  mplayerLoadSubtitle( guiInfo.SubtitleFilename );
          break;
/*   case fsOtherSelector:
          setddup( &guiInfo.Othername,fsSelectedDirectory,fsSelectedFile );
          break;*/
   case fsAudioSelector:
          setddup( &guiInfo.AudioFilename,fsSelectedDirectory,fsSelectedFile );
          break;
   case fsFontSelector:
          setddup( &font_name,fsSelectedDirectory,fsSelectedFile );
	  mplayerLoadFont();
	  if ( Preferences ) gtk_entry_set_text( GTK_ENTRY( prEFontName ),font_name );
	  break;
  }

 HideFileSelect();

 item=fsTopList_items;
 while( item )
  {
   if ( !strcmp( item->data,fsSelectedDirectory ) ) i=0;
   item=item->next;
  }
 if ( i ) fsTopList_items=g_list_prepend( fsTopList_items,(gchar *)get_current_dir_name_utf8() );
 if ( uiLoadPlay ) { uiLoadPlay=False; uiEvent( evPlay,0 ); }
  else gui( GUI_SET_STATE,(void *) GUI_STOP );
}
示例#24
0
static void fs_fsFilterCombo_activate( GtkEntry * entry,
                                       gpointer user_data )
{
 fsFilter=gtk_entry_get_text( GTK_ENTRY( user_data ) );
 CheckDir( fsFNameList );
}
示例#25
0
文件: funcs.c 项目: bbs-io/mbse
/*
 * Function will check and create a home directory for the user if
 * needed. It will also change into the users home directory when
 * they login.
 */
char *ChangeHomeDir(char *Name, int Mailboxes)
{
    char	*temp;
    static char	temp1[PATH_MAX];
    FILE	*fp;

    temp  = calloc(PATH_MAX, sizeof(char));

    /*
     * set umask bits to zero's then reset with mkdir
     */
    umask(000);
	
    /*
     * First check to see if users home directory exists
     * else try create directory, as set in CFG.bbs_usersdir
     */
    if ((access(CFG.bbs_usersdir, R_OK)) != 0) {
	WriteError("$FATAL: Access to %s failed", CFG.bbs_usersdir);
	free(temp);
	ExitClient(MBERR_INIT_ERROR);
    }

    snprintf(temp1, PATH_MAX, "%s/%s", CFG.bbs_usersdir, Name);

    /*
     * Then check to see if users directory exists in the home dir
     */
    if ((access(temp1, R_OK)) != 0) {
	WriteError("$FATAL: Users homedir %s doesn't exist", temp1);
	free(temp);
	ExitClient(MBERR_INIT_ERROR);
    }

    /*
     * Change to users home directory
     */
    if (chdir(temp1) != 0) {
	WriteError("$FATAL: Can't change to users home dir, aborting: %s", temp1);
	free(temp);
	ExitClient(MBERR_INIT_ERROR);
    }
    setenv("HOME", temp1, 1);

    /*
     * Check if user has a .signature file.
     * If not, create a simple one.
     */
    snprintf(temp, PATH_MAX, "%s/%s/.signature", CFG.bbs_usersdir, Name);
    if (access(temp, R_OK)) {
	Syslog('+', "Creating users .signature file");
        if ((fp = fopen(temp, "w")) == NULL) {
	    WriteError("$Can't create %s", temp);
	} else {
	    fprintf(fp,     "    Greetings, %s\n", exitinfo.sUserName);
	    if ((CFG.EmailMode == E_PRMISP) && exitinfo.Email && CFG.GiveEmail)
	        fprintf(fp, "    email: %s@%s\n", exitinfo.Name, CFG.sysdomain);
	    fclose(fp);
	}
    }

    /*
     * Check subdirectories, create them if they don't exist.
     */
    snprintf(temp, PATH_MAX, "%s/wrk", temp1);
    CheckDir(temp);
    snprintf(temp, PATH_MAX, "%s/tag", temp1);
    CheckDir(temp);
    snprintf(temp, PATH_MAX, "%s/upl", temp1);
    CheckDir(temp);
    snprintf(temp, PATH_MAX, "%s/tmp", temp1);
    CheckDir(temp);
    snprintf(temp, PATH_MAX, "%s/.dosemu", temp1);
    CheckDir(temp);
    snprintf(temp, PATH_MAX, "%s/.dosemu/run", temp1);
    CheckDir(temp);
    snprintf(temp, PATH_MAX, "%s/.dosemu/tmp", temp1);
    CheckDir(temp);
    umask(007);

    /*
     * Check users private emailboxes
     */
    if (Mailboxes) {
	snprintf(temp, PATH_MAX, "%s/mailbox", temp1);
	if (Msg_Open(temp))
	    Msg_Close();
	snprintf(temp, PATH_MAX, "%s/archive", temp1);
	if (Msg_Open(temp))
	    Msg_Close();
	snprintf(temp, PATH_MAX, "%s/trash", temp1);
	if (Msg_Open(temp))
	    Msg_Close();
    }
	
    free(temp);
    return temp1;
}
示例#26
0
文件: layout.C 项目: VisCore618/FFVC
// #################################################################
//
void LAYOUT::ReadInputFile(TextParser* tpCntl)
{
  string str,buff;
  string label,label_base,label_leaf;
  
  // node数の取得
  int nnode=0;
  label_base = "/LayoutData";
  if ( tpCntl->chkNode(label_base) )  //nodeがあれば
  {
    nnode = tpCntl->countLabels(label_base);
  }
  
  // dfi_nameの取得
  dfi_name.clear();
  for (int i=0; i<nnode; i++) {
    
    if ( !(tpCntl->getNodeStr(label_base, i+1, str)) )
    {
      printf("\tParsing error : No Elem name\n");
      Exit(0);
    }
    if( strcasecmp(str.substr(0,4).c_str(), "list") ) continue;
    label=label_base+"/"+str;
    
    if ( !(tpCntl->getInspectedValue(label, buff )) ) {
      printf("\tParsing error : fail to get '%s'\n", label.c_str());
      Exit(0);
    }
    //FList[ilist].name = str;
    dfi_name.push_back(buff.c_str());
    
  }
  
#if 0
  cout << "dfi_name.size() = " << dfi_name.size() << endl;
  vector<string>::const_iterator it;
  for (it = dfi_name.begin(); it != dfi_name.end(); it++) {
    cout << "name = " << (*it).c_str() << endl;
  }
#endif
  
  // dfi_nameの取得
  mname.clear();
  dname.clear();
  rankis.clear();
  rankie.clear();
  label_base = "/LayoutData";
  for (int i=0; i<nnode; i++) {
    
    if ( !(tpCntl->getNodeStr(label_base, i+1, str)) )
    {
      printf("\tParsing error : No Elem name\n");
      Exit(0);
    }
    if( strcasecmp(str.substr(0,6).c_str(), "divide") ) continue;
    
    label=label_base+"/"+str+"/machine";
    if ( !(tpCntl->getInspectedValue(label, buff )) ) {
      printf("\tParsing error : fail to get '%s'\n", label.c_str());
      Exit(0);
    }
    mname.push_back(buff.c_str());
    
    label=label_base+"/"+str+"/rank";
    int v[2];
    for (int n=0; n<2; n++) v[n]=0;
    if ( !(tpCntl->getInspectedVector(label, v, 2)) ) {
      printf("\tParsing error : fail to get '%s'\n", label.c_str());
      Exit(0);
    }
    rankis.push_back(v[0]);
    rankie.push_back(v[1]);
    
    label=label_base+"/"+str+"/dir";
    if ( !(tpCntl->getInspectedValue(label, buff )) ) {
      printf("\tParsing error : fail to get '%s'\n", label.c_str());
      Exit(0);
    }
    dname.push_back(buff.c_str());
  }
  
  
  //出力ディレクトリの指定 ---> 実行オプションよりこちらが優先される
  label = "/LayoutData/OutputDir";
  if ( (tpCntl->getInspectedValue(label, str )) )
  {
    dirname=str;
    CheckDir(dirname);
    if( dirname.size() != 0 ) dirname=dirname+"/";
  }
  
  // DivideFunc ---> 出力を項目別にファイル分割するオプション
  label = "/LayoutData/FFVDivideFunc";
  
  if ( !(tpCntl->getInspectedValue(label, str )) )
  {
    Hostonly_ stamped_printf("\tParsing error : fail to get '%s'\n", label.c_str());
    Exit(0);
  }
  else
  {
    if     ( !strcasecmp(str.c_str(), "on") )  IS_DivideFunc = ON;
    else if( !strcasecmp(str.c_str(), "off") ) IS_DivideFunc = OFF;
    else
    {
      Hostonly_ stamped_printf("\tInvalid keyword is described for '%s'\n", label.c_str());
      Exit(0);
    }
  }
  
  
  // FileNameGrid --- option
  label = "/LayoutData/Plot3dOptions/FileNameGrid";
  
  if ( !(tpCntl->getInspectedValue(label, str)) )
  {
    basename_g = "PLOT3DoutputGrid";
  }
  else
  {
    basename_g = str;
  }
  if ( basename_g.empty() )
  {
    basename_g = "PLOT3DoutputGrid";
  }
  
  // FileNameFunc --- option
  label = "/LayoutData/Plot3dOptions/FileNameFunc";
  
  if ( !(tpCntl->getInspectedValue(label, str)) )
  {
    basename_f = "PLOT3Doutput";
  }
  else
  {
    basename_f = str;
  }
  if ( basename_f.empty() )
  {
    basename_f = "PLOT3Doutput";
  }
  
}
示例#27
0
文件: file.c 项目: bbs-io/mbse
/*
 * Download files already tagged, called from the menu.
 */
void Download(void)
{
    FILE	    *tf, *fd;
    int		    rc = 0, i, Count = 0, OldArea;
    char	    *local, *temp;
    int		    Size = 0, CostSize = 0, dsize;
    struct _fdbarea *fdb_area = NULL;
    down_list	    *dl = NULL, *tmpf;

    Enter(2);
    OldArea = iAreaNumber;
    WhosDoingWhat(DOWNLOAD, NULL);

    /*
     * Clean users tag directory.
     */
    temp = calloc(PATH_MAX, sizeof(char));
    snprintf(temp, PATH_MAX, "-rf %s/%s/tag", CFG.bbs_usersdir, exitinfo.Name);
    execute_pth((char *)"rm", temp, (char *)"/dev/null", (char *)"/dev/null", (char *)"/dev/null");
    snprintf(temp, PATH_MAX, "%s/%s/tag", CFG.bbs_usersdir, exitinfo.Name);
    CheckDir(temp);

    if ((tf = fopen("taglist", "r+")) == NULL) {
	Syslog('+', "Download command but no files marked");
	/* No files marked for download. */
	pout(LIGHTRED, BLACK, (char *) Language(258));
	Enter(2);
	Pause();
	return;
    }

    local   = calloc(PATH_MAX, sizeof(char));
    /* Checking your marked downloads, please wait... */
    pout(LIGHTMAGENTA, BLACK, (char *) Language(255));
    Enter(2);

    ReadExitinfo();
    while (fread(&Tag, sizeof(Tag), 1, tf) == 1) {
	if (Tag.Active) {

	    SetFileArea(Tag.Area);

	    /*
	     * Check password for selected file  FIXME: Where???
	     */
	    memset(&fdb, 0, sizeof(fdb));
	    if ((fdb_area = mbsedb_OpenFDB(Tag.Area, 30)) != NULL) {
		while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
		    if (strcmp(fdb.LName, Tag.LFile) == 0)
			break;
		}
		mbsedb_CloseFDB(fdb_area);
	    }

	    if (strcmp(fdb.LName, Tag.LFile) == 0) {
		Syslog('b', "Found file %s in area %d", fdb.LName, Tag.Area);
		if (fdb.Deleted) {
		    /* Sorry that file is unavailable for download */
		    snprintf(temp, 81, "%s (%s)", (char *) Language(248), fdb.LName);
		    poutCR(CFG.HiliteF, CFG.HiliteB, temp);
		    Tag.Active = FALSE;
		    Syslog('+', "File %s in area %d unavailable for download, deleted", fdb.LName, Tag.Area);
		}
	    }

	    if (Tag.Active) {
		/*
		 * Create/Append file description list while we're
		 * busy checking. If the users doesn't want it we
		 * can unlink it aftwerwards. We also insert CR
		 * characters to please the poor DOS (M$oft) users.
		 */
		snprintf(local, PATH_MAX, "./tag/filedesc.%d", exitinfo.Downloads % 256);
		if ((fd = fopen(local, "a")) != NULL) {
		    fprintf(fd, "%s (%s)\r\n", fdb.LName, fdb.Name);
		    for (i = 0; i < 25; i++) {
			if (strlen(fdb.Desc[i]) > 1)
			    fprintf(fd, "  %s\r\n", fdb.Desc[i]);
		    }
		    fprintf(fd, "\r\n");
		    fclose(fd);
		    Syslog('b', "Added info to %s", local);
		} else {
		    WriteError("Can't add info to %s", local);
		}

		snprintf(local, PATH_MAX, "%s/%s", sAreaPath, Tag.LFile);
		add_download(&dl, local, Tag.LFile, Tag.Area, fdb.Size, FALSE);

		Home();
	    } 

	    if (!Tag.Active) {
		/*
		 * Update the download active flag in the
		 * taglist
		 */
		fseek(tf, - sizeof(Tag), SEEK_CUR);
		fwrite(&Tag, sizeof(Tag), 1, tf);
		Syslog('b', "Download file %s marked inactive in taglist", Tag.LFile);
	    } else {
		/*
		 * Count file and sizes.
		 */
		Count++;
		Size += fdb.Size;
		if (!area.Free)
		    CostSize += fdb.Size;
	    }
	}
    }
    fclose(tf);

    /*
     * If anything left to download...
     */
    if (!Count) {
	SetFileArea(OldArea);
	unlink("taglist");
	/* No files marked for download */
	pout(LIGHTRED, BLACK, (char *) Language(258));
	Enter(2);
	Pause();
	free(temp);
	free(local);
	tidy_download(&dl);
	Syslog('+', "No files left to download");
	return;
    }

    /*
     * Add descriptions file to the queue.
     */
    snprintf(local, PATH_MAX, "%s/%s/tag/filedesc.%d", CFG.bbs_usersdir, exitinfo.Name, exitinfo.Downloads % 256);
    dsize = file_size(local);
    snprintf(temp, PATH_MAX, "filedesc.%d", exitinfo.Downloads % 256);
    add_download(&dl, local, temp, 0, dsize, TRUE);
    free(local);

    /* You have */ /* files( */ /* bytes) marked for download */
    snprintf(temp, PATH_MAX, "%s %d %s%d %s", (char *) Language(249), Count, (char *) Language(280), Size, (char *) Language(281));
    pout(YELLOW, BLACK, temp);
    Enter(2);

    if (!CheckBytesAvailable(CostSize)) {
	SetFileArea(OldArea);
	free(temp);
	tidy_download(&dl);
	return;
    }

    Pause();

    if ((rc = download(dl))) {
	/*
	 * Download error
	 */
	Syslog('+', "Download error rc=%d", rc);
	free(temp);
	tidy_download(&dl);
	return;
    }
    
    /*
     * Checking the successfull sent files, they are missing from
     * the ./tag directory. Failed files are still there.
     */
    PUTCHAR('\r');
    /* Updating download counters, please wait ... */
    pout(LIGHTCYAN, BLACK, (char *) Language(352));
    Count = Size = 0; 

    /*
     * Update downloadcounters, don't log anything because the state
     * of sucessfull sent files is already logged by the download
     * function.
     */
    if ((tf = fopen("taglist", "r+")) != NULL) {
	while (fread(&Tag, sizeof(Tag), 1, tf) == 1) {
	    PUTCHAR('.');
	    if (Tag.Active) {
		for (tmpf = dl; tmpf; tmpf = tmpf->next) {
		    if (strcmp(tmpf->remote, Tag.LFile) == 0) {
			if (tmpf->sent) {
		
			    Tag.Active = FALSE;
			    fseek(tf, - sizeof(Tag), SEEK_CUR);
			    fwrite(&Tag, sizeof(Tag), 1, tf);

			    /*
			     * Update the download counter and the last download date.
			     */
			    SetFileArea(Tag.Area);
			    if ((fdb_area = mbsedb_OpenFDB(Tag.Area, 30))) {
				while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
				    if (strcmp(fdb.LName, Tag.LFile) == 0)
					break;
				}
				Size += fdb.Size;
				fdb.TimesDL++;
				fdb.LastDL = time(NULL);
				if (mbsedb_LockFDB(fdb_area, 30)) {
				    fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
				    fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
				    mbsedb_UnlockFDB(fdb_area);
				}
				mbsedb_CloseFDB(fdb_area);
				Count++;
			    }
			}
			break;
		    }
		}
	    }
	}
	fclose(tf);
    }
    Enter(2);

    /*
     * Update the users record.
     */
    ReadExitinfo();

    exitinfo.Downloads += Count;          /* Increase download counter      */
    mib_downloads      += Count;
    exitinfo.DownloadK += (Size / 1024);  /* Increase amount download today */
    mib_kbdownload     += (Size / 1024);

    /*
     * Minus the amount downloaded today from downloadktoday
     * if less than zero, it won't let the user download anymore.
     */
    if (LIMIT.DownK || LIMIT.DownF) {
	exitinfo.DownloadKToday -= (Size / 1024);
    }

    WriteExitinfo();
    Pause();
    SetFileArea(OldArea);
    free(temp);
    tidy_download(&dl);
}