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); }
public static CabeceraAxman LoadFromArray(byte[] bytes) { CabeceraAxman cab = new CabeceraAxman (); cab.version = Utilidades.UtArrays.LeerTexto (bytes, 0, 15); cab.fragmento = UtArrays.LeerInt32 (bytes, 15); cab.checksum = UtArrays.LeerInt32 (bytes, 19); return cab; }