コード例 #1
0
ファイル: ColaAxman3.cs プロジェクト: albfernandez/dalle
        public static new ColaAxman LoadFromFile(string file)
        {
            byte[] b = UtilidadesFicheros.LeerSeek (file, new FileInfo(file).Length -4, 4);
            int tRuta = UtArrays.LeerInt32 (b, 0);

            b = UtilidadesFicheros.LeerSeek(file, new FileInfo(file).Length - (tRuta + 39), tRuta + 39);

            if (b[0] != SEPARADOR)
                throw new Exception ("");

            ColaAxman3 c = new ColaAxman3();

            c.fichOriginal = "";
            int i=0;
            for (i = 1; b[i] != SEPARADOR; i++){
                c.fichOriginal += Convert.ToChar(b[i]);
            }
            i++;
            c.version = "";
            for ( ; b[i] != SEPARADOR; i++){
                c.version += Convert.ToChar(b[i]);
            }
            i++;

            // Leemos la versión
            c.ver = UtArrays.LeerInt32 (b, i);
            i+=4;
            if (b[i] != SEPARADOR)
                throw new Exception();
            i++;

            // Leemos el fragmento
            c.fragmentos = UtArrays.LeerInt32(b, i);
            i+=4;
            if (b[i] != SEPARADOR)
                throw new Exception();
            i++;

            c.tamanoOriginal = UtArrays.LeerInt64(b, i);
            i+=8;
            if (b[i] != SEPARADOR)
                throw new Exception ();

            return c;
        }
コード例 #2
0
ファイル: Axman3.cs プロジェクト: albfernandez/dalle
        protected override void _Partir(string fichero,string sal1, string dir, long kb)
        {
            if ((sal1 == null) || (sal1 == string.Empty))
                sal1 = new FileInfo (fichero).Name;
            string formato = dir + Path.DirectorySeparatorChar + sal1 + ".{0}.axman";
            int i = 1;
            long transferidos = 0;
            long totales = new FileInfo(fichero).Length;
            //if (totales < (kb*1024)){
            //	string msg = string.Format (I.__("Source file is too small"));
            //	throw new Exception ("El fichero es más pequeño que los fragmentos");
            //}
            long tf = kb*1024 - 23;
            OnProgress (0,1);
            CabeceraAxman cab = new CabeceraAxman ();
            AxmanCRC crc = new AxmanCRC();
            do {

                cab.Fragmento = i;
                crc.Reset();
                String destino = String.Format(formato, i);
                UtilidadesFicheros.ComprobarSobreescribir(destino);
                UtilidadesFicheros.Append (destino, cab.ToByteArray());
                transferidos += UtilidadesFicheros.CopiarIntervalo (
                    fichero, destino, transferidos, tf, crc);
                cab.Checksum = (int) crc.Value;

                // Escribimos la cabecera.
                UtilidadesFicheros.Sobreescribir (destino, cab.ToByteArray(), 0);

                if (transferidos == totales){
                    //Escribimos la cola.
                    ColaAxman3 cola = new ColaAxman3();
                    cola.FicheroOriginal = "C:\\temp\\"+fichero;
                    cola.Version = "AXMAN_03-12r   ";
                    cola.Ver = 3;
                    cola.Fragmentos = i;
                    cola.TamanoOriginal = totales;
                    UtilidadesFicheros.Append (destino, cola.ToByteArray());
                }
                OnProgress (transferidos, totales);

                i++;
            }while (transferidos < totales);
        }