FlashFxp Queue File Generation (to used with Romcenter)

这两天小补了一下MAME(logiqx DatFile Mame 0.90b),拿RC扫了一遍,红的黄的14xx个....快崩溃了,偶硬盘上的fullset还停留在0.71b呢.....于是用FlashFXP登陆到FTP上面去补,于是照着RC生成的Mamemiss.txt (缺失列表) 一个一个去点....点了3分钟,ft,眼睛花了:( 干脆用C#整了个FlashFXP Queue File (下载队列文件) 自动生成工具,世界清净了....就靠着这个,Mame090b补完,CPS1/CPS2 200501补完,NeoGeo 200501补完,GBA Nointro 1896补完..... 

操作步骤:
1. 用RC扫描自己有的romset,生成Mamemiss.txt列表
2. 用下面的程序,以Mamemiss.txt为输入,生成多份FlashFXP fqf文件 - 1.fqf、2.fqf....
3. 多打开几个FlashFXP,一个个Ctrl+L Load Queue....逐一选上1.fqf、2.fqf...,All Ctrl+Z!
4. 去睡觉....一觉醒来以后,就fullset了....

提示:请自行修改程序中Main里面的配置参数! 为了程序简洁起见,错误处理一概无视....

感想:哪天要是能够做个机器人帮偶补rom就圆满了......CM+QueueGen Batch Processing....

using System;
using System.IO;
using System.Text;

namespace QueueGen
{
    
class MainApp
    
{
        [STAThread]
        
static void Main(string[] args)
        
{
            
//FlashFXP站点管理器中的站点名称
            const String SOURCE_HOST="Emuz";
            
//FTP源目录名
            const String SOURCE_DIR="/pub/Roms/MAME ROMs/";
            
//本机目的子目录名
            const String TARGET_DIR="C:\\Documents and Settings\\LUY\\Desktop\\roms\\";

            
//RC生成的MissGame文件
            const String DATA_FILE="../../MAMEmissM.txt";
            
//输出的队列文件存放的目录
            const String QUEUE_FILE_DIR="../../";

            
//输出分为几份队列文件?(用于多FlashFXP Session下载)
            const int QUEUE_FILE_COUNT=3;

            QueueGen qg
=new QueueGen(QUEUE_FILE_COUNT,
                        SOURCE_HOST,SOURCE_DIR,
                        TARGET_DIR,
                        DATA_FILE,QUEUE_FILE_DIR);
            qg.GenQueueFile();
        }

    }


    
class QueueGen
    
{
        
private int Count;

        
private String FileType="0";
        
private String Direction="5";
        
private String TargetHost="-";
        
private String FileSize="1";

        
private String SourceFilename;
        
private String TargetFilename;
        
        
private String SourceHost;
        
private String SourceDir;
        
private String TargetDir;
        
        
private String DataFile;
        
private String QueueFileDir;
                
        
private StreamReader sr;
        
private FileStream[] fs;
        
private BinaryWriter[] w;
        
        
public QueueGen(int CT,String SH,String SD,String TD,String DF,String QD)
        
{
            Count
=CT;
            SourceHost
=SH;
            SourceDir
=SD;
            TargetDir
=TD;
            DataFile
=DF;
            QueueFileDir
=QD;
        }

        
        
public void GenQueueFile()
        
{
            OpenAllFiles();

            
int idx=0;
            
int fileidx=0;
            
byte[] buf=new byte[1024*10];

            
while ((SourceFilename=sr.ReadLine())!=null
            
{
                Console.WriteLine(SourceFilename);
                
                SourceFilename
=SourceFilename+".zip";
                TargetFilename
=SourceFilename;

                idx
=0;
                AppendBuf(FileType,buf,
ref idx);
                AppendBuf(
1,buf,ref idx);
                AppendBuf(Direction,buf,
ref idx);
                AppendBuf(
1,buf,ref idx);
                AppendBuf(
2,buf,ref idx);
                AppendBuf(SourceHost,buf,
ref idx);
                AppendBuf(
1,buf,ref idx);
                AppendBuf(
2,buf,ref idx);
                AppendBuf(TargetHost,buf,
ref idx);
                AppendBuf(
1,buf,ref idx);
                AppendBuf(SourceDir,buf,
ref idx);
                AppendBuf(SourceFilename,buf,
ref idx);
                AppendBuf(
1,buf,ref idx);
                AppendBuf(TargetDir,buf,
ref idx);
                AppendBuf(TargetFilename,buf,
ref idx);
                AppendBuf(
1,buf,ref idx);
                AppendBuf(FileSize,buf,
ref idx);
                AppendBuf(
0x0d,buf,ref idx);
                AppendBuf(
0x0a,buf,ref idx);

                w[fileidx].Write(buf,
0,idx);
                fileidx
=(fileidx+1)%Count;
            }


            CloseAllFiles();
        }


        
private void OpenAllFiles()
        
{
            sr 
= new StreamReader(DataFile);
            
            fs 
= new FileStream[Count];
            w 
= new BinaryWriter[Count];
            
            
for (int i=1;i<=Count;i++)
            
{
                String fn
=QueueFileDir+i.ToString()+".fqf";
                fs[i
-1]=new FileStream(fn, FileMode.Create);
                w[i
-1= new BinaryWriter(fs[i-1]);
            }
    
        }


        
private void CloseAllFiles()
        
{
            
for (int i=0;i<Count;i++)
            
{
                w[i].Close();
                fs[i].Close();
            }


            sr.Close();
        }

        
        
private void AppendBuf(String s,byte[] buf,ref int idx)
        
{
            ASCIIEncoding ascii 
= new ASCIIEncoding();
            ascii.GetBytes(s,
0,s.Length,buf,idx);
            idx
+=s.Length;
        }


        
private void AppendBuf(byte b,byte[] buf,ref int idx)
        
{
            buf[idx]
=b;
            idx
++;
        }

    }

}
posted @ 2005-01-19 17:50  neoragex2002  阅读(1306)  评论(6编辑  收藏  举报