2002-07-03 14:48:48 +00:00
|
|
|
|
#include <agasys.h>
|
1995-09-11 15:13:50 +00:00
|
|
|
|
#include <archives.h>
|
|
|
|
|
#include <config.h>
|
2007-12-12 09:38:51 +00:00
|
|
|
|
#include <diction.h>
|
1995-09-11 15:13:50 +00:00
|
|
|
|
#include <isam.h>
|
|
|
|
|
#include <progind.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
2007-12-12 09:38:51 +00:00
|
|
|
|
#include <nditte.h>
|
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TArchive
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
int TArchive::build_backup_list(int mode, long firm, TString_array& fl) const
|
1995-09-11 15:13:50 +00:00
|
|
|
|
{
|
|
|
|
|
fl.destroy();
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
|
|
|
|
if (mode & 0x1)
|
1995-09-11 15:13:50 +00:00
|
|
|
|
fl.add(firm2dir(0L));
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
|
|
|
|
if (mode & 0x2)
|
|
|
|
|
{
|
|
|
|
|
if (firm <= 0L)
|
|
|
|
|
{
|
|
|
|
|
TLocalisamfile ditte(LF_NDITTE);
|
|
|
|
|
for (int err = ditte.first(); err == NOERR; err = ditte.next())
|
1998-04-30 14:54:04 +00:00
|
|
|
|
{
|
2007-12-12 09:38:51 +00:00
|
|
|
|
const char* dir = firm2dir(ditte.get_long(NDT_CODDITTA));
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (fexist(dir))
|
|
|
|
|
fl.add(dir);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
fl.add(firm2dir(firm));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (mode & 0x4)
|
|
|
|
|
{
|
1995-09-11 15:13:50 +00:00
|
|
|
|
TFilename name(firm2dir(-1)); // __ptprf
|
|
|
|
|
name.add("config"); // Aggiungi configurazioni
|
1998-04-30 14:54:04 +00:00
|
|
|
|
if (name.exist())
|
1995-09-11 15:13:50 +00:00
|
|
|
|
fl.add(name);
|
2000-05-05 15:25:49 +00:00
|
|
|
|
}
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (mode & 0x8)
|
|
|
|
|
{
|
|
|
|
|
TFilename name(firm2dir(-1)); // __ptprf
|
|
|
|
|
name.add("M770"); // Aggiungi 770
|
|
|
|
|
if (fexist(name))
|
|
|
|
|
fl.add(name);
|
|
|
|
|
}
|
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
|
return fl.items();
|
|
|
|
|
}
|
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
|
// @doc EXTERNAL
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
|
// @mfunc Costruisce la lista delle directory da scompattare
|
|
|
|
|
//
|
2000-10-03 13:45:12 +00:00
|
|
|
|
// @rdesc Ritorna il numero di cartelle da ripristinare
|
1996-02-05 19:00:53 +00:00
|
|
|
|
int TArchive::build_restore_list(
|
2000-05-05 15:25:49 +00:00
|
|
|
|
int& mode,
|
1996-02-05 19:00:53 +00:00
|
|
|
|
long firm, // @parm Ditta di cui effettuare il salvataggio
|
|
|
|
|
char floppy, // @parm Floppy su cui effettuare il backup
|
2001-05-04 10:59:04 +00:00
|
|
|
|
TString_array& fl) const // @parm Nomi dell cartelle da ripristinare
|
1995-09-11 15:13:50 +00:00
|
|
|
|
{
|
1998-05-27 10:56:30 +00:00
|
|
|
|
fl.destroy();
|
2001-04-30 15:04:10 +00:00
|
|
|
|
|
|
|
|
|
if (!yesno_box("Inserire il dischetto nel drive %c e continuare?\n"
|
2000-05-05 15:25:49 +00:00
|
|
|
|
"(Rispondere NO se si desidera interrompere la procedura)", floppy))
|
2001-04-30 15:04:10 +00:00
|
|
|
|
return -1;
|
2000-05-05 15:25:49 +00:00
|
|
|
|
|
|
|
|
|
TFilename name("a:/backup.ini"); name[0] = floppy;
|
|
|
|
|
TConfig ini(name);
|
|
|
|
|
TString_array pl;
|
|
|
|
|
const int max = ini.list_paragraphs(pl); // Lista degli archivi
|
|
|
|
|
for (int i = 0; i < max; i++)
|
|
|
|
|
{
|
|
|
|
|
const TString& name = pl.row(i);
|
|
|
|
|
const int disk = ini.get_int("Disk", name);
|
|
|
|
|
if (disk == 1)
|
|
|
|
|
{
|
|
|
|
|
if (atol(name) > 0L)
|
|
|
|
|
{
|
|
|
|
|
if (mode & 0x2)
|
|
|
|
|
{
|
|
|
|
|
const long frm = atol(name);
|
|
|
|
|
if (firm <= 0L || firm == frm)
|
|
|
|
|
fl.add(firm2dir(frm)); // Aggiungi gli archivi della ditta
|
|
|
|
|
if (firm > 0L)
|
|
|
|
|
mode &= ~0x2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
1999-05-24 13:34:11 +00:00
|
|
|
|
{
|
2000-05-05 15:25:49 +00:00
|
|
|
|
if (name.compare("com", -1, TRUE) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (mode & 0x1)
|
|
|
|
|
mode &= ~0x1;
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (name.compare("config", -1, TRUE) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (mode & 0x4)
|
|
|
|
|
mode &= ~0x4;
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (name.compare("m770", -1, TRUE) == 0)
|
|
|
|
|
{
|
|
|
|
|
if (mode & 0x8)
|
|
|
|
|
mode &= ~0x8;
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TFilename fn(firm2dir(-1)); // __ptprf
|
|
|
|
|
fn.add(name);
|
|
|
|
|
fl.add(fn);
|
|
|
|
|
}
|
1999-05-24 13:34:11 +00:00
|
|
|
|
}
|
2000-05-05 15:25:49 +00:00
|
|
|
|
}
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
|
|
return fl.items();
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-24 13:34:11 +00:00
|
|
|
|
// @doc EXTERNAL
|
|
|
|
|
|
|
|
|
|
// @mfunc Scrive il file backup.ini sul drive indicato
|
|
|
|
|
//
|
|
|
|
|
// @rdesc Ritorna se e' riuscito a scrivere il file
|
|
|
|
|
bool TArchive::write_ini(TFilename& work, int disk, long tot, const char* desc, char floppy) const
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
TFilename parag(work.name()); parag.ext("");
|
|
|
|
|
TFilename ini("a:/backup.ini"); ini[0] = floppy;
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
|
|
|
|
|
if (fexist(ini))
|
|
|
|
|
{
|
|
|
|
|
TConfig c(ini, parag);
|
|
|
|
|
const int d = c.get_int("Disk");
|
|
|
|
|
if (d == disk)
|
|
|
|
|
{
|
2007-12-12 09:38:51 +00:00
|
|
|
|
ok = yesno_box(FR("Il disco %d contiene gia' un backup della cartella %s del %s"
|
|
|
|
|
"\nSi desidera continuare?"),
|
1999-05-24 13:34:11 +00:00
|
|
|
|
disk, (const char*)parag, (const char*)c.get("Date"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FILE* i = fopen(ini, "w"); // Crea il file backup.ini per evitare messaggi
|
|
|
|
|
fclose(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
TConfig c(ini, parag);
|
|
|
|
|
const char* oggi = TDate(TODAY).string();
|
|
|
|
|
c.set("Size", tot , NULL, TRUE);
|
|
|
|
|
c.set("Disk", disk, NULL, TRUE);
|
|
|
|
|
c.set("Description", desc, NULL, TRUE);
|
|
|
|
|
c.set("Date", oggi, NULL, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
|
bool TArchive::move_file(const TFilename& file, const char* dir) const
|
|
|
|
|
{
|
|
|
|
|
TFilename dest(dir);
|
|
|
|
|
dest.add(file.name());
|
|
|
|
|
|
|
|
|
|
long filesize = ::fsize(file);
|
|
|
|
|
filesize -= ::fsize(dest);
|
|
|
|
|
|
|
|
|
|
bool space_ok = filesize <= 0;
|
|
|
|
|
while (!space_ok)
|
|
|
|
|
{
|
2007-12-18 10:57:26 +00:00
|
|
|
|
space_ok = xvt_fsys_test_disk_free_space(dir, filesize) != 0;
|
1998-04-30 14:54:04 +00:00
|
|
|
|
if (!space_ok)
|
|
|
|
|
{
|
|
|
|
|
TString msg(128);
|
2008-01-17 14:04:05 +00:00
|
|
|
|
msg.format(FR("Lo spazio disponibile e' insufficiente:\nNecessario: %.1lf Mb; Disponibile: %ld Mb\n"),
|
|
|
|
|
filesize/1024.0, xvt_fsys_get_disk_free_space(dir, 'M'));
|
2007-12-18 10:57:26 +00:00
|
|
|
|
if (xvt_fsys_is_floppy_drive(dir))
|
2007-12-12 09:38:51 +00:00
|
|
|
|
msg << TR("Inserire un nuovo disco e ritentare?");
|
1998-04-30 14:54:04 +00:00
|
|
|
|
else
|
2007-12-12 09:38:51 +00:00
|
|
|
|
msg << TR("Liberare dello spazio e ritentare?");
|
1998-04-30 14:54:04 +00:00
|
|
|
|
if (!yesno_box(msg))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool write_ok = TRUE;
|
|
|
|
|
bool user_abort = FALSE;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
write_ok = ::fcopy(file, dest);
|
|
|
|
|
if (write_ok)
|
|
|
|
|
::remove(file);
|
|
|
|
|
else
|
|
|
|
|
{
|
2007-12-12 09:38:51 +00:00
|
|
|
|
if (!yesno_box(FR("Errore di copia del file %s.\nSi desidera riprovare?"),
|
1998-04-30 14:54:04 +00:00
|
|
|
|
(const char*)file))
|
|
|
|
|
user_abort = TRUE;
|
|
|
|
|
}
|
|
|
|
|
} while (!write_ok && !user_abort);
|
|
|
|
|
|
|
|
|
|
return write_ok;
|
|
|
|
|
}
|
|
|
|
|
|
2002-07-03 14:48:48 +00:00
|
|
|
|
bool TArchive::split_file(const TFilename& archive, unsigned long max_chunk) const
|
|
|
|
|
{
|
|
|
|
|
TFilename output(archive);
|
|
|
|
|
output.ext("z00");
|
|
|
|
|
|
|
|
|
|
int disk = 0;
|
|
|
|
|
unsigned long scritti = 0;
|
|
|
|
|
|
|
|
|
|
FILE* i = fopen(archive, "rb");
|
|
|
|
|
if (i == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
FILE* o = fopen(output, "wb");
|
|
|
|
|
|
|
|
|
|
const int BUFSIZE = 1024*16;
|
|
|
|
|
TString buf(BUFSIZE);
|
|
|
|
|
char* buffer = buf.get_buffer();
|
|
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
while (ok)
|
|
|
|
|
{
|
|
|
|
|
const size_t letti = fread(buffer, 1, BUFSIZE, i);
|
|
|
|
|
if (letti == 0)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (scritti >= max_chunk)
|
|
|
|
|
{
|
|
|
|
|
fclose(o);
|
|
|
|
|
|
|
|
|
|
TString16 ext; ext.format("z%02d", ++disk);
|
|
|
|
|
output.ext(ext);
|
|
|
|
|
o = fopen(output, "wb");
|
|
|
|
|
scritti = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ok = fwrite(buffer, letti, 1, o) > 0;
|
|
|
|
|
scritti += letti;
|
|
|
|
|
}
|
|
|
|
|
fclose(i);
|
|
|
|
|
fclose(o);
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
|
bool TArchive::fsplit_zip(
|
|
|
|
|
const char* filename, // @parm Nome del file da spezzare
|
|
|
|
|
char floppy, // @parm Floppy su cui scaricare il file
|
|
|
|
|
const char* desc) const // @parm Descrizione dell'archivio
|
|
|
|
|
{
|
|
|
|
|
const TFilename archive(filename);
|
|
|
|
|
|
|
|
|
|
unsigned long size = 0;
|
|
|
|
|
TFilename path; path << floppy << ':';
|
|
|
|
|
|
|
|
|
|
while (size <= 0)
|
|
|
|
|
{
|
2007-12-12 09:38:51 +00:00
|
|
|
|
if (xvt_fsys_is_floppy_drive(path))
|
|
|
|
|
message_box(FR("Inserire il disco 1 nel drive %c:"), floppy);
|
2003-03-28 15:32:17 +00:00
|
|
|
|
size = xvt_fsys_get_disk_size(path, 'K') - 64;
|
1998-04-30 14:54:04 +00:00
|
|
|
|
if (size <= 0)
|
|
|
|
|
{
|
2007-12-12 09:38:51 +00:00
|
|
|
|
if (!yesno_box(FR("Errore di accesso al drive %c\nSi desidera ritentare?"), floppy))
|
1998-04-30 14:54:04 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
do_events();
|
|
|
|
|
}
|
|
|
|
|
|
2004-03-12 14:39:04 +00:00
|
|
|
|
const unsigned long minsize = 360*1024L;
|
1998-04-30 14:54:04 +00:00
|
|
|
|
if (size < minsize)
|
|
|
|
|
size = minsize;
|
|
|
|
|
|
2002-07-03 14:48:48 +00:00
|
|
|
|
if (!split_file(archive, size))
|
2007-12-12 09:38:51 +00:00
|
|
|
|
return error_box(FR("Errore durante lo splitting del file %s"), (const char*)archive);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
size = ::fsize(archive);
|
|
|
|
|
::remove(archive);
|
|
|
|
|
|
2002-07-03 14:48:48 +00:00
|
|
|
|
for (int d = 0; ; d++)
|
1998-04-30 14:54:04 +00:00
|
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
|
TString16 ext; ext.format("z%02d", d);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
TFilename src(archive);
|
2002-07-03 14:48:48 +00:00
|
|
|
|
src.ext(ext);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
if (src.exist())
|
|
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
|
if (d > 0)
|
1998-04-30 14:54:04 +00:00
|
|
|
|
{
|
2007-12-12 09:38:51 +00:00
|
|
|
|
message_box(FR("Inserire il disco %d nel drive %c:"), d+1, floppy);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
do_events();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (move_file(src, path))
|
|
|
|
|
{
|
|
|
|
|
TFilename ini(path);
|
|
|
|
|
ini.add("backup.ini");
|
|
|
|
|
TConfig c(ini, archive.name());
|
|
|
|
|
c.set("Size", size);
|
2002-07-03 14:48:48 +00:00
|
|
|
|
c.set("Disk", d+1);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
c.set("Description", desc);
|
|
|
|
|
c.set("Date", TDate(TODAY).string());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @doc EXTERNAL
|
|
|
|
|
|
|
|
|
|
// @mfunc Effettua il backup della directory
|
|
|
|
|
//
|
|
|
|
|
// @rdesc Ritorna il risultato dell'operazione
|
|
|
|
|
bool TArchive::zip(
|
|
|
|
|
const char* dir, // @parm Directory di cui effettuare il backup
|
|
|
|
|
char floppy, // @parm Floppy su cui effettuare il backup
|
|
|
|
|
const char* desc) // @parm Descrizione da assegnare al backup
|
|
|
|
|
// @parm long | firm | Ditta di cui effettuare il backup
|
|
|
|
|
|
|
|
|
|
// @syntax bool backup(const char* dir, char floppy, const char* desc, bool pr_set);
|
|
|
|
|
// @syntax bool backup(long firm, char floppy, const char* desc, bool pr_set);
|
|
|
|
|
|
|
|
|
|
// @comm Il parametro <p pr_set> e' utilizzato per evitare errori di riaperture di files.
|
|
|
|
|
|
|
|
|
|
{
|
2003-05-16 14:24:47 +00:00
|
|
|
|
safely_close_closeable_isamfiles();
|
|
|
|
|
|
|
|
|
|
DIRECTORY currdir, newdir;
|
|
|
|
|
xvt_fsys_get_dir( &currdir); //memorizza la directory dove e'
|
|
|
|
|
|
|
|
|
|
xvt_fsys_convert_str_to_dir(dir, &newdir); //converte il nome della directory
|
|
|
|
|
xvt_fsys_set_dir( &newdir); //passa alla directory dir che gli viene passata
|
|
|
|
|
|
2002-07-03 14:48:48 +00:00
|
|
|
|
const TFilename workdir = dir;
|
|
|
|
|
const TString name = workdir.name();
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
// Nome del file compresso
|
|
|
|
|
TFilename work; work.tempdir(); work.add(name); work.ext("zip");
|
|
|
|
|
|
2007-12-12 09:38:51 +00:00
|
|
|
|
TString title(TR("Archiviazione")); title << ' ' << workdir;
|
1998-04-30 14:54:04 +00:00
|
|
|
|
TIndwin waitw(100,title,FALSE,FALSE);
|
|
|
|
|
TWait_cursor hourglass;
|
2003-05-16 14:24:47 +00:00
|
|
|
|
|
|
|
|
|
TString_array filenames;
|
|
|
|
|
list_files("*.*", filenames);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
// Crea il file con la lista dei file da comprimere
|
|
|
|
|
const char* const ZIPLIST = "ziplist.txt";
|
|
|
|
|
FILE* flist = fopen(ZIPLIST, "w");
|
2003-05-16 14:24:47 +00:00
|
|
|
|
|
|
|
|
|
FOR_EACH_ARRAY_ROW(filenames, r, row)
|
|
|
|
|
fprintf(flist, "%s\n",(const char *)*row);
|
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
|
fclose(flist);
|
|
|
|
|
|
2002-07-03 14:48:48 +00:00
|
|
|
|
bool ok = ::aga_zip_filelist(ZIPLIST, work);
|
2003-05-16 14:24:47 +00:00
|
|
|
|
|
2003-05-16 14:45:05 +00:00
|
|
|
|
remove(ZIPLIST); //elimina il file di testo con la lista dei files
|
|
|
|
|
|
2003-05-16 14:24:47 +00:00
|
|
|
|
xvt_fsys_set_dir( &currdir); //torna a posizionarsi nella directory iniziale
|
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
ok = fsplit_zip(work, floppy, desc);
|
|
|
|
|
else
|
2007-12-12 09:38:51 +00:00
|
|
|
|
error_box(TR("Compressione degli archivi errata o incompleta"));
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-04 10:59:04 +00:00
|
|
|
|
bool TArchive::zip(int mode, long firm, char floppy, const char* desc)
|
1998-04-30 14:54:04 +00:00
|
|
|
|
{
|
|
|
|
|
TString_array fl;
|
2001-05-04 10:59:04 +00:00
|
|
|
|
const int num_ditte = build_backup_list(mode, firm, fl);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
for (int f = 0; f < num_ditte; f++)
|
|
|
|
|
{
|
|
|
|
|
ok = zip(fl.row(f), floppy, desc);
|
|
|
|
|
if (!ok) break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @doc EXTERNAL
|
|
|
|
|
|
|
|
|
|
// @mfunc Effettua il restore della directory
|
|
|
|
|
//
|
|
|
|
|
// @rdesc Ritorna il risultato dell'operazione
|
|
|
|
|
bool TArchive::unzip(
|
|
|
|
|
const char* dir, // @parm Directory di cui effettuare il restore
|
2004-04-19 09:38:43 +00:00
|
|
|
|
char floppy, // @parm Unita' da cui leggere i dati
|
1998-04-30 14:54:04 +00:00
|
|
|
|
bool tmp) // @parm Directory temporanea da utilizzare
|
|
|
|
|
// @syntax bool restore(const char* dir, char floppy, bool temp, bool pr_set);
|
|
|
|
|
// @syntax bool restore(long firm, char floppy, bool temp, bool pr_set);
|
|
|
|
|
// @comm Il parametro <p pr_set> e' utilizzato per evitare errori di riaperture di files.
|
|
|
|
|
{
|
|
|
|
|
TFilename work;
|
|
|
|
|
if (tmp)
|
|
|
|
|
work.tempdir();
|
|
|
|
|
else
|
|
|
|
|
work = dir;
|
|
|
|
|
|
|
|
|
|
TFilename output(dir);
|
|
|
|
|
output = output.name();
|
|
|
|
|
output.ext("zip");
|
|
|
|
|
|
2007-12-12 09:38:51 +00:00
|
|
|
|
if (!yesno_box(FR("Attenzione l'archivio %c:\\%s verra' ripristinato\n"
|
|
|
|
|
"nel direttorio %s. Continuare?"),
|
1998-04-30 14:54:04 +00:00
|
|
|
|
floppy, (const char*)output, (const char*)work))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
bool ok = work.exist();
|
|
|
|
|
if (!ok)
|
|
|
|
|
{
|
2007-12-12 09:38:51 +00:00
|
|
|
|
ok = yesno_box(FR("Non esiste il direttorio %s: si desidera crearlo?"), (const char*)work);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
{
|
|
|
|
|
make_dir(work);
|
|
|
|
|
ok = work.exist();
|
|
|
|
|
}
|
|
|
|
|
if (!ok)
|
2007-12-12 09:38:51 +00:00
|
|
|
|
return error_box(FR("Impossibile accedere a %s"), (const char*)work);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-12-12 09:38:51 +00:00
|
|
|
|
TString title(TR("Ripristino")); title << ' ' << output;
|
1998-04-30 14:54:04 +00:00
|
|
|
|
TIndwin waitw(100,title,FALSE,FALSE);
|
|
|
|
|
|
2003-05-16 14:24:47 +00:00
|
|
|
|
safely_close_closeable_isamfiles();
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
TFilename cfg;
|
|
|
|
|
cfg << floppy << ':';
|
|
|
|
|
cfg.add("backup.ini");
|
|
|
|
|
TConfig c(cfg, output.name());
|
2002-07-03 14:48:48 +00:00
|
|
|
|
const unsigned long total_size = c.get_long("Size");
|
|
|
|
|
unsigned long read_size = 0;
|
|
|
|
|
|
|
|
|
|
TFilename restored;
|
2003-05-16 14:45:05 +00:00
|
|
|
|
restored.tempdir();
|
2002-07-03 14:48:48 +00:00
|
|
|
|
restored.add(output.name());
|
|
|
|
|
restored.ext("zip");
|
|
|
|
|
|
|
|
|
|
for (int d = 0; read_size < total_size; d++)
|
1998-04-30 14:54:04 +00:00
|
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
|
TString16 ext; ext.format("z%02d", d);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
TFilename src;
|
2004-04-19 09:38:43 +00:00
|
|
|
|
src << floppy << ':' << SLASH;
|
|
|
|
|
src << output.name();
|
2002-07-03 14:48:48 +00:00
|
|
|
|
src.ext(ext);
|
2007-12-12 09:38:51 +00:00
|
|
|
|
if (xvt_fsys_is_floppy_drive(src))
|
2004-09-22 10:24:54 +00:00
|
|
|
|
message_box("Inserire il disco %d contenente il file %s", d+1, (const char*)src);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
while (!src.exist())
|
|
|
|
|
{
|
|
|
|
|
if (!yesno_box("Impossibile aprire il file %s:\nSi desidera ritentare?",
|
|
|
|
|
(const char *)src))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (src.exist())
|
|
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
|
fcopy(src, restored, d > 0);
|
|
|
|
|
read_size = ::fsize(restored);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
2002-07-03 14:48:48 +00:00
|
|
|
|
ok = read_size == total_size;
|
|
|
|
|
if (ok)
|
2003-05-16 14:45:05 +00:00
|
|
|
|
{
|
2002-07-03 14:48:48 +00:00
|
|
|
|
ok = ::aga_unzip(restored, work);
|
2003-05-16 14:45:05 +00:00
|
|
|
|
if (ok)
|
|
|
|
|
remove(restored);
|
|
|
|
|
}
|
2002-07-03 14:48:48 +00:00
|
|
|
|
else
|
|
|
|
|
error_box("Il file %s non <20> stato ripristinato completamente", (const char*)restored);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
2001-05-04 10:59:04 +00:00
|
|
|
|
bool TArchive::unzip(int mode, long firm, char floppy, bool temp)
|
1998-04-30 14:54:04 +00:00
|
|
|
|
{
|
|
|
|
|
TString_array fl;
|
2001-05-04 10:59:04 +00:00
|
|
|
|
const int num_ditte = build_restore_list(mode, firm, floppy, fl);
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
|
for (int f = 0; f < num_ditte; f++)
|
|
|
|
|
{
|
|
|
|
|
ok = unzip(fl.row(f), floppy, temp);
|
|
|
|
|
if (!ok) break;
|
|
|
|
|
}
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
1998-06-23 14:30:08 +00:00
|
|
|
|
|
1999-01-19 09:15:17 +00:00
|
|
|
|
bool TArchive::backup(const char* dir, char floppy, const char* desc, bool)
|
1998-06-23 14:30:08 +00:00
|
|
|
|
{
|
|
|
|
|
return zip(dir, floppy, desc);
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-04 10:59:04 +00:00
|
|
|
|
bool TArchive::backup(int mode, long firm, char floppy, const char* desc, bool)
|
1998-06-23 14:30:08 +00:00
|
|
|
|
{
|
2001-05-04 10:59:04 +00:00
|
|
|
|
return zip(mode, firm, floppy, desc);
|
1998-06-23 14:30:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-01-19 09:15:17 +00:00
|
|
|
|
bool TArchive::restore(const char* dir, char floppy, bool tmp, bool)
|
1998-06-23 14:30:08 +00:00
|
|
|
|
{
|
|
|
|
|
return unzip(dir, floppy, tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2001-05-04 10:59:04 +00:00
|
|
|
|
bool TArchive::restore(int mode, long firm, char floppy, bool tmp, bool)
|
1998-06-23 14:30:08 +00:00
|
|
|
|
{
|
2001-05-04 10:59:04 +00:00
|
|
|
|
return unzip(mode, firm, floppy, tmp);
|
1998-06-23 14:30:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|