1995-09-11 15:13:50 +00:00
|
|
|
#include <direct.h>
|
1997-01-17 11:07:43 +00:00
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
#if XVT_OS == XVT_OS_WIN
|
1997-01-17 11:07:43 +00:00
|
|
|
#define XVT_INCL_NATIVE
|
|
|
|
#define STRICT
|
1998-04-30 14:54:04 +00:00
|
|
|
#endif
|
1997-01-17 11:07:43 +00:00
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
#include <archives.h>
|
|
|
|
#include <config.h>
|
1998-04-30 14:54:04 +00:00
|
|
|
#include <defmask.h>
|
|
|
|
#include <execp.h>
|
1995-09-11 15:13:50 +00:00
|
|
|
#include <isam.h>
|
|
|
|
#include <mask.h>
|
1998-04-30 14:54:04 +00:00
|
|
|
#include <os_dep.h>
|
|
|
|
#include <prefix.h>
|
1995-09-11 15:13:50 +00:00
|
|
|
#include <progind.h>
|
|
|
|
#include <urldefid.h>
|
|
|
|
#include <utility.h>
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
|
|
|
|
#include <al.h>
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TProgress_win declaration
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TProgress_win : public TMask
|
|
|
|
{
|
|
|
|
ALWindowsMessage* _monitor;
|
|
|
|
TArchive* _arc;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static bool cancel_handler(TMask_field&, KEY k);
|
|
|
|
|
|
|
|
public:
|
|
|
|
ALWindowsMessage* monitor() const { return _monitor; }
|
|
|
|
|
|
|
|
TProgress_win(const char* title, TArchive* = NULL);
|
|
|
|
~TProgress_win();
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TArchive
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
|
|
|
// @mfunc Funzione per richiedere all'utente il dischetto e per controllare la
|
1996-05-08 14:10:35 +00:00
|
|
|
// corretta sequenza dei dischetti da inserire
|
1996-02-05 19:00:53 +00:00
|
|
|
//
|
|
|
|
// @rdesc Ritorna il puntatore al file presente (o meno) sul dischetto
|
|
|
|
FILE* TArchive::ask_disk(
|
1996-05-08 14:10:35 +00:00
|
|
|
TFilename& name, // @parm Nome del file da creare/cercare su disco
|
|
|
|
int disk, // @parm Numero progressivo del set
|
|
|
|
char floppy, // @parm Drive sul quale effettuare l'operazione (A, B, C, ...)
|
|
|
|
bool lettura) const // @parm Indica il modo di apertura del file:
|
|
|
|
//
|
|
|
|
// @flag TRUE | Apre il file in lettura
|
|
|
|
// @flag FALSE | Apre il file in scrittura
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
TFilename prev(name);
|
1998-04-30 14:54:04 +00:00
|
|
|
TString16 ext; ext.format("%03d", disk-1);
|
|
|
|
prev.ext(ext); // File precedente
|
1995-09-11 15:13:50 +00:00
|
|
|
bool first = TRUE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (first)
|
|
|
|
{
|
1998-04-30 14:54:04 +00:00
|
|
|
message_box("Inserire il disco %d nel drive %c:\n"
|
1998-06-10 16:38:58 +00:00
|
|
|
"File '%s'", disk, floppy, (const char*)prev.name());
|
1995-09-11 15:13:50 +00:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const bool ok = yesno_box("Inserire il disco %d nel drive %c\n"
|
1997-10-30 16:14:49 +00:00
|
|
|
"Estrarre il disco %d e continuare?",
|
|
|
|
disk, floppy, disk-1);
|
1995-09-11 15:13:50 +00:00
|
|
|
if (!ok) return NULL;
|
|
|
|
}
|
1998-02-24 10:37:28 +00:00
|
|
|
} while (prev.exist()); // Non facciamo i furbetti!
|
1998-04-30 14:54:04 +00:00
|
|
|
|
|
|
|
ext.format("%03d", disk);
|
|
|
|
name.ext(ext); // File attuale
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
FILE* f = NULL;
|
|
|
|
bool retry = TRUE;
|
|
|
|
while (retry)
|
|
|
|
{
|
|
|
|
f = fopen(name, lettura ? "rb" : "wb");
|
|
|
|
if (f == NULL)
|
|
|
|
retry = yesno_box("Il file %s non e' accessibile: riprovare?", (const char*)name);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setvbuf(f, NULL, _IOFBF, BUFSIZE);
|
|
|
|
retry = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
|
1998-05-13 15:01:03 +00:00
|
|
|
#endif
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
long TArchive::fsize(FILE* f) const
|
|
|
|
{
|
|
|
|
CHECK(f, "Can't measure NULL file");
|
|
|
|
fseek(f, 0, SEEK_END);
|
|
|
|
const long s = ftell(f);
|
|
|
|
fseek(f, 0, SEEK_SET);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TArchive::build_backup_list(long firm, TString_array& fl) const
|
|
|
|
{
|
|
|
|
fl.destroy();
|
|
|
|
if (firm < 0L)
|
|
|
|
{
|
|
|
|
fl.add(firm2dir(0L));
|
|
|
|
TLocalisamfile ditte(LF_NDITTE);
|
|
|
|
for (int err = ditte.first(); err == NOERR; err = ditte.next())
|
|
|
|
{
|
1998-04-30 14:54:04 +00:00
|
|
|
const long cod = ditte.get_long("CODDITTA");
|
|
|
|
if (prefix().exist(cod))
|
|
|
|
{
|
|
|
|
TFilename dir = firm2dir(cod);
|
1995-09-11 15:13:50 +00:00
|
|
|
fl.add(dir);
|
1998-04-30 14:54:04 +00:00
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fl.add(firm2dir(firm));
|
|
|
|
|
|
|
|
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
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna il numero di direttori da ripristinare
|
|
|
|
int TArchive::build_restore_list(
|
|
|
|
long firm, // @parm Ditta di cui effettuare il salvataggio
|
|
|
|
char floppy, // @parm Floppy su cui effettuare il backup
|
|
|
|
TString_array& fl) const // @parm Nomi dei direttori da ripristinare
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
1998-05-27 10:56:30 +00:00
|
|
|
fl.destroy();
|
1995-09-11 15:13:50 +00:00
|
|
|
if (firm < 0) // Crea lista automaticamente
|
|
|
|
{
|
|
|
|
TFilename name("a:/backup.ini"); name[0] = floppy;
|
1998-05-27 10:56:30 +00:00
|
|
|
TConfig ini(name);
|
|
|
|
TString_array pl;
|
|
|
|
const int max = ini.list_paragraphs(pl); // Lista degli archivi
|
|
|
|
for (int i = 0; i < max; i++)
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
1998-05-27 10:56:30 +00:00
|
|
|
const TString& name = pl.row(i);
|
|
|
|
const int disk = ini.get_int("Disk", name);
|
1995-09-11 15:13:50 +00:00
|
|
|
if (disk == 1)
|
1998-05-27 10:56:30 +00:00
|
|
|
{
|
|
|
|
if (name == "config")
|
|
|
|
{
|
|
|
|
TFilename fn(firm2dir(-1)); // __ptprf
|
|
|
|
fn.add(name); // Aggiungi configurazioni
|
|
|
|
fl.add(fn);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
firm = atol(name);
|
|
|
|
fl.add(firm2dir(firm)); // Aggiungi gli archivi che iniziano qui
|
|
|
|
}
|
1995-09-11 15:13:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-05-27 10:56:30 +00:00
|
|
|
fl.add(firm2dir(firm)); // Inserisci solo una ditta (o COM)
|
1995-09-11 15:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return fl.items();
|
|
|
|
}
|
|
|
|
|
1998-05-13 15:01:03 +00:00
|
|
|
#if XVT_OS == XVT_OS_WIN
|
|
|
|
|
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 Spezza il file in modo da farlo stare sul dischetto
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna se e' riuscito a spezzare il file
|
|
|
|
bool TArchive::fsplit(
|
1998-04-30 14:54:04 +00:00
|
|
|
const char* filename, // @parm Nome del file da spezzare
|
1996-05-08 14:10:35 +00:00
|
|
|
char floppy, // @parm Floppy su cui scaricare il file
|
|
|
|
const char* desc) const // @parm Descrizione dell'archivio
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
const TFilename from(filename); // File da splittare
|
|
|
|
|
|
|
|
FILE* i = fopen(from, "rb"), *o = NULL;
|
|
|
|
if (i == NULL) return error_box("Impossibile aprire il file '%s'", from);
|
|
|
|
setvbuf(i, NULL, _IOFBF, BUFSIZE);
|
|
|
|
|
|
|
|
const long tot = fsize(i);
|
1998-05-27 10:56:30 +00:00
|
|
|
long scritti = 0;
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
TFilename work;
|
|
|
|
work << floppy << ":/" << from.name(); // File su dischetto
|
|
|
|
|
1997-10-30 16:14:49 +00:00
|
|
|
TString msg("Archiviazione di "); msg << work << " (" << (tot/1024) << "K)";
|
1995-09-11 15:13:50 +00:00
|
|
|
TProgind w(tot, msg, TRUE, TRUE, 40);
|
1998-05-27 10:56:30 +00:00
|
|
|
|
|
|
|
if (!os_test_disk_free_space(work, tot))
|
|
|
|
{
|
1998-06-10 16:38:58 +00:00
|
|
|
TString16 dev("A:/*.*"); dev[0] = floppy; //
|
1998-05-27 10:56:30 +00:00
|
|
|
TString_array dir;
|
|
|
|
if (list_files(dev, dir) > 0)
|
|
|
|
{
|
|
|
|
warning_box("Il file %s non puo' essere contenuto per intero nel dischetto corrente:\n"
|
|
|
|
"Accertarsi di aver inserito un dischetto formattato e completamente vuoto prima di continuare.",
|
|
|
|
(const char*)from.name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
int disk = 0;
|
|
|
|
TString buffer(BUFSIZE);
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
while (ok)
|
|
|
|
{
|
|
|
|
const size_t letti = fread((char*)(const char*)buffer, 1, BUFSIZE, i);
|
|
|
|
|
|
|
|
if (o != NULL)
|
|
|
|
ok = (letti > 0) ? (fwrite((char*)(const char*)buffer, letti, 1, o) == 1) : TRUE;
|
|
|
|
else
|
|
|
|
ok = FALSE;
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (o != NULL)
|
|
|
|
{
|
|
|
|
chsize(fileno(o),scritti); // Must truncate output file or some information will be rewritten on next disk!
|
|
|
|
scritti = 0; // Reset count bytes written to disk.
|
|
|
|
fclose(o);
|
|
|
|
}
|
|
|
|
o = ask_disk(work, ++disk, floppy, FALSE);
|
|
|
|
ok = o != NULL;
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
TFilename parag(work.name()); parag.ext("");
|
|
|
|
TFilename ini("a:/backup.ini"); ini[0] = floppy;
|
|
|
|
|
1998-02-24 10:37:28 +00:00
|
|
|
if (ini.exist())
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
TConfig c(ini, parag);
|
|
|
|
const int d = c.get_int("Disk");
|
|
|
|
if (d == disk)
|
|
|
|
{
|
|
|
|
ok = yesno_box("Il disco %d contiene gia' un backup del direttorio %s del %s"
|
|
|
|
"\nSi desidera continuare?",
|
|
|
|
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);
|
|
|
|
}
|
1998-05-27 10:56:30 +00:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
TConfig c(ini, parag);
|
|
|
|
const char* oggi = TDate(TODAY).string();
|
|
|
|
c.set("Date", oggi);
|
|
|
|
c.set("Description", desc);
|
|
|
|
c.set("Disk", disk);
|
|
|
|
c.set("Size", tot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
ok = (letti > 0) ? (fwrite((char*)(const char*)buffer, letti, 1, o) == 1) : TRUE;
|
1998-04-30 14:54:04 +00:00
|
|
|
if (!ok)
|
|
|
|
error_box("Impossibile scrivere i dati sul dischetto");
|
1995-09-11 15:13:50 +00:00
|
|
|
else
|
|
|
|
scritti +=letti;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scritti += letti;
|
|
|
|
w.addstatus(letti);
|
|
|
|
if (ok)
|
|
|
|
ok = !w.iscancelled();
|
|
|
|
if (letti < BUFSIZE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(i);
|
|
|
|
if (o != NULL) fclose(o);
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
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 Ricostruisce il file spezzato
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna se e' riuscito a ricostruire il file
|
|
|
|
bool TArchive::fbuild(
|
|
|
|
const char* filename, // @parm Nome del file da ricostrutire
|
1996-05-08 14:10:35 +00:00
|
|
|
char floppy) const // @parm Floppy da cui recupare i pezzi del file
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
const TFilename work(filename);
|
|
|
|
|
|
|
|
FILE* o = fopen(work, "wb"), *i = NULL;
|
|
|
|
if (o == NULL)
|
|
|
|
return error_box("Impossibile creare il file '%s'", (const char*)work);
|
|
|
|
setvbuf(o, NULL, _IOFBF, BUFSIZE);
|
|
|
|
|
|
|
|
long totale = 0L; // Bytes letti
|
|
|
|
long max = 1440000L; // Bytes da leggere
|
|
|
|
TFilename name; // Nome del file su dischetto
|
|
|
|
name << floppy << ":/" << work.name();
|
|
|
|
|
|
|
|
TString256 msg("Ripristino da "); msg << name;
|
1997-10-30 16:14:49 +00:00
|
|
|
TProgind w(max, msg, TRUE, TRUE, 40);
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
int disk = 0;
|
|
|
|
TString buffer(BUFSIZE);
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
while (ok)
|
|
|
|
{
|
|
|
|
size_t letti = 0;
|
|
|
|
if (i != NULL)
|
|
|
|
{
|
|
|
|
letti = fread((char*)(const char*)buffer, 1, BUFSIZE, i);
|
|
|
|
ok = letti > 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok = FALSE;
|
|
|
|
|
|
|
|
if (!ok) // Richiedi nuovo disco
|
|
|
|
{
|
|
|
|
if (i != NULL) fclose(i);
|
|
|
|
i = ask_disk(name, ++disk, floppy, TRUE);
|
|
|
|
ok = i != NULL;
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
if (disk == 1)
|
|
|
|
{
|
|
|
|
TFilename ini("a:/backup.ini"); ini[0] = floppy;
|
1998-04-30 14:54:04 +00:00
|
|
|
if (ini.exist())
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
TFilename parag(name.name()); parag.ext("");
|
|
|
|
TConfig c(ini, parag);
|
|
|
|
max = c.get_long("Size");
|
|
|
|
}
|
|
|
|
else ok = yesno_box("Manca il file %s: continuare ugualmente?", (const char*)ini);
|
|
|
|
}
|
|
|
|
w.setmax(max);
|
|
|
|
|
|
|
|
if (ok) // Leggi primo blocco di bytes
|
|
|
|
{
|
|
|
|
letti = fread((char*)(const char*)buffer, 1, BUFSIZE, i);
|
|
|
|
ok = letti > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ok) // La lettura e stata fatta bene
|
|
|
|
{
|
|
|
|
ok = fwrite((char*)(const char*)buffer, 1, letti, o) == letti;
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
w.addstatus(letti);
|
|
|
|
totale += letti;
|
|
|
|
ok = !w.iscancelled();
|
|
|
|
}
|
1997-10-30 16:14:49 +00:00
|
|
|
else
|
|
|
|
error_box("Impossibile scrivere i dati sul file %s", (const char*)work);
|
1995-09-11 15:13:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok || totale == max) // Esci in caso di errore o se hai finito
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(o);
|
|
|
|
if (i != NULL) fclose(i);
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
|
|
|
// @mfunc Effettua il backup della ditta o della directory
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna il risultato dell'operazione
|
|
|
|
bool TArchive::backup(
|
|
|
|
const char* dir, // @parm Directory di cui effettuare il backup
|
|
|
|
char floppy, // @parm Floppy su cui effettuare il backup
|
1998-04-30 14:54:04 +00:00
|
|
|
const char* desc) // @parm Descrizione da assegnare al backup
|
1996-05-08 14:10:35 +00:00
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @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.
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
const TString16 old(prefix().name());
|
1998-04-30 14:54:04 +00:00
|
|
|
prefix().set(NULL);
|
1995-09-11 15:13:50 +00:00
|
|
|
|
1998-05-27 10:56:30 +00:00
|
|
|
DIRECTORY curdir; xvt_fsys_get_dir(&curdir);
|
1995-09-11 15:13:50 +00:00
|
|
|
chdir(dir);
|
|
|
|
|
|
|
|
const TFilename d(dir);
|
|
|
|
const TString16 name(d.name());
|
|
|
|
TFilename work; work.tempdir(); work.add(name); work.ext("gal");
|
|
|
|
|
1998-05-27 10:56:30 +00:00
|
|
|
// Cancella eventuali gal residui
|
|
|
|
TString_array gals;
|
|
|
|
list_files("*.gal", gals);
|
|
|
|
list_files("*.000", gals);
|
|
|
|
for (int g = gals.items()-1; g >= 0; g--)
|
|
|
|
::remove(gals.row(g));
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
_arc = new ALArchive(work);
|
|
|
|
|
1997-10-30 16:14:49 +00:00
|
|
|
TString title("Archiviazione di "); title << name;
|
1995-09-11 15:13:50 +00:00
|
|
|
TProgress_win w(title, this);
|
|
|
|
ALEntryList list(w.monitor());
|
1997-11-24 17:12:02 +00:00
|
|
|
_arc->AddWildCardFiles(list, "*.*", 1);
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
w.open_modal();
|
|
|
|
_arc->Create( list );
|
|
|
|
w.close_modal();
|
|
|
|
|
|
|
|
bool ok = _arc->mStatus == AL_SUCCESS;
|
|
|
|
if (ok)
|
|
|
|
ok = fsplit(work, floppy, desc);
|
|
|
|
else
|
|
|
|
error_box("Compressione degli archivi errata o incompleta:\n%s",
|
|
|
|
_arc->mStatus.GetStatusDetail());
|
|
|
|
|
|
|
|
delete _arc; _arc = NULL;
|
|
|
|
|
|
|
|
remove(work);
|
1998-05-27 10:56:30 +00:00
|
|
|
|
|
|
|
xvt_fsys_set_dir(&curdir);
|
1998-04-30 14:54:04 +00:00
|
|
|
prefix().set(old);
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
bool TArchive::backup(long firm, char floppy, const char* desc)
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
TString_array fl;
|
|
|
|
const int num_ditte = build_backup_list(firm, fl);
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
for (int f = 0; f < num_ditte; f++)
|
|
|
|
{
|
1998-04-30 14:54:04 +00:00
|
|
|
ok = backup(fl.row(f), floppy, desc);
|
1995-09-11 15:13:50 +00:00
|
|
|
if (!ok) break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1996-02-05 19:00:53 +00:00
|
|
|
// @doc EXTERNAL
|
|
|
|
|
|
|
|
// @mfunc Effettua il restore della ditta o dell directory
|
|
|
|
//
|
|
|
|
// @rdesc Ritorna il risultato dell'operazione
|
|
|
|
bool TArchive::restore(
|
|
|
|
const char* dir, // @parm Directory di cui effettuare il restore
|
|
|
|
char floppy, // @parm Floppy da cui leggere i dati
|
1998-04-30 14:54:04 +00:00
|
|
|
bool tmp) // @parm Directory temporanea da utilizzare
|
1996-02-05 19:00:53 +00:00
|
|
|
|
|
|
|
// @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);
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
|
|
|
TFilename work;
|
|
|
|
if (tmp)
|
|
|
|
work.tempdir();
|
|
|
|
else
|
|
|
|
work = dir;
|
|
|
|
|
|
|
|
TFilename output(dir);
|
|
|
|
output = output.name(); output.ext("gal");
|
|
|
|
|
|
|
|
if (!yesno_box("Attenzione l'archivio sul disco %c: verra' ripristinato\n"
|
|
|
|
"nel direttorio %s. Continuare?", floppy, (const char*)work))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
xvt_fsys_save_dir();
|
|
|
|
bool ok = chdir(work) == 0;
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
ok = yesno_box("Non esiste il direttorio %s: si desidera crearlo?", (const char*)work);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
make_dir(work);
|
|
|
|
ok = chdir(work) == 0;
|
|
|
|
}
|
|
|
|
if (!ok)
|
|
|
|
return error_box("Impossibile accedere a %s", (const char*)work);
|
|
|
|
}
|
|
|
|
|
|
|
|
const TString16 old(prefix().name());
|
1998-04-30 14:54:04 +00:00
|
|
|
prefix().set(NULL);
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
ok = fbuild(output, floppy);
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
_arc = new ALArchive(output);
|
1997-11-26 11:18:39 +00:00
|
|
|
|
|
|
|
TAssoc_array subdirs; // Array dei sottodirettori da creare
|
1995-09-11 15:13:50 +00:00
|
|
|
TProgress_win w("Ripristino", this);
|
|
|
|
ALEntryList list(w.monitor());
|
|
|
|
_arc->ReadDirectory(list);
|
|
|
|
|
1997-11-26 11:18:39 +00:00
|
|
|
// Naviga attraverso l'archivio e compone l'array dei sottodirettori da creare
|
|
|
|
ALEntry *entry = list.GetFirstEntry();
|
|
|
|
TFilename path;
|
|
|
|
|
|
|
|
while (entry)
|
|
|
|
{
|
|
|
|
path = entry->mpStorageObject->mName;
|
|
|
|
path = path.path();
|
|
|
|
if (path.not_empty() && subdirs.objptr(path) == NULL) // Se non c'e' lo aggiunge alla lista
|
|
|
|
if (!fexist(path))
|
|
|
|
subdirs.add(path,path);
|
|
|
|
entry = entry->GetNextEntry();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Scorre la lista dei sottodirettori da creare
|
|
|
|
for (TFilename* p = (TFilename*)subdirs.first_item(); p != NULL; p = (TFilename*)subdirs.succ_item())
|
|
|
|
{
|
|
|
|
p->rtrim(1); // Strip trailing /
|
|
|
|
make_dir(*p);
|
|
|
|
}
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
w.open_modal();
|
|
|
|
_arc->Extract( list );
|
|
|
|
|
|
|
|
ok = _arc->mStatus == AL_SUCCESS;
|
|
|
|
if (!ok) error_box("Ripristino degli archivi errato o incompleto:\n%s",
|
|
|
|
_arc->mStatus.GetStatusString());
|
|
|
|
w.close_modal();
|
|
|
|
delete _arc; _arc = NULL;
|
|
|
|
|
|
|
|
remove(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
xvt_fsys_restore_dir();
|
1998-04-30 14:54:04 +00:00
|
|
|
prefix().set(old);
|
1995-09-11 15:13:50 +00:00
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
bool TArchive::restore(long firm, char floppy, bool temp)
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
1998-05-27 10:56:30 +00:00
|
|
|
bool lastdisk = firm >= 0;
|
1995-09-11 15:13:50 +00:00
|
|
|
bool ok = TRUE;
|
1998-05-27 10:56:30 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
TString_array fl;
|
|
|
|
const int num_ditte = build_restore_list(firm, floppy, fl);
|
|
|
|
|
|
|
|
for (int f = 0; f < num_ditte; f++)
|
|
|
|
{
|
|
|
|
const TToken_string& code = fl.row(f);
|
|
|
|
|
|
|
|
ok = restore(code, floppy, temp);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
if (!lastdisk)
|
|
|
|
lastdisk = code.find("config") >= 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lastdisk)
|
|
|
|
{
|
|
|
|
TFilename cfg("a:/config.001"); cfg[0] = floppy;
|
|
|
|
if (!fexist(cfg))
|
|
|
|
lastdisk = !yesno_box("Si desidera procedere col prossimo disco di ripristino?\n"
|
|
|
|
"(Rispondere NO se si desidera interrompere la procedura)");
|
|
|
|
}
|
|
|
|
} while(!lastdisk);
|
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
void TArchive::stop_job()
|
|
|
|
{
|
|
|
|
if (_arc != NULL)
|
|
|
|
_arc->GetStorageObject()->mStatus.SetError(AL_USER_ABORT, "Interrotto dall'utente");
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TProgress_win implementation
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
TProgress_win::TProgress_win(const char* title, TArchive* arc)
|
1998-02-24 10:37:28 +00:00
|
|
|
: TMask(title, 1, 60, 6), _arc(arc), _monitor(NULL)
|
1995-09-11 15:13:50 +00:00
|
|
|
{
|
1996-05-08 14:10:35 +00:00
|
|
|
RCT rct;
|
1996-05-23 13:21:43 +00:00
|
|
|
xvt_rect_set(&rct, CHARX, CHARY, 58*CHARX, 5*CHARY/2);
|
1996-05-08 14:10:35 +00:00
|
|
|
WINDOW wtxt = xvt_ctl_create(WC_EDIT, &rct, "", win(), CTL_FLAG_DISABLED, (long)this, 101);
|
1996-05-23 13:21:43 +00:00
|
|
|
xvt_rect_set(&rct, 28*CHARX, 3*CHARY, 33*CHARX, 9*CHARY/2);
|
1996-05-08 14:10:35 +00:00
|
|
|
WINDOW wnum = xvt_ctl_create(WC_EDIT, &rct, "", win(), CTL_FLAG_DISABLED, (long)this, 102);
|
|
|
|
|
1996-05-23 13:21:43 +00:00
|
|
|
add_button(DLG_USER, 0, "Cancel", -11, -1, 10, 2, "", BMP_CANCEL);
|
1995-09-11 15:13:50 +00:00
|
|
|
set_handler(DLG_USER, cancel_handler);
|
|
|
|
|
|
|
|
HWND txt = (HWND)xvt_vobj_get_attr(wtxt, ATTR_NATIVE_WINDOW);
|
|
|
|
HWND num = (HWND)xvt_vobj_get_attr(wnum, ATTR_NATIVE_WINDOW);
|
|
|
|
_monitor = new ALWindowsMessage(AL_MONITOR_OBJECTS, txt, AL_SEND_RATIO, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
TProgress_win::~TProgress_win()
|
|
|
|
{
|
|
|
|
if (_monitor) delete _monitor;
|
|
|
|
}
|
1996-05-08 14:10:35 +00:00
|
|
|
|
1995-09-11 15:13:50 +00:00
|
|
|
bool TProgress_win::cancel_handler(TMask_field& f, KEY k)
|
|
|
|
{
|
|
|
|
if (k == K_SPACE)
|
|
|
|
{
|
|
|
|
TProgress_win& m = (TProgress_win&)f.mask();
|
|
|
|
if (m._arc != NULL)
|
|
|
|
m._arc->stop_job();
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
space_ok = ::os_test_disk_free_space(dest, filesize);
|
|
|
|
if (!space_ok)
|
|
|
|
{
|
|
|
|
TString msg(128);
|
|
|
|
msg << "Lo spazio sull'unita' e' insufficiente:\n";
|
|
|
|
if (::os_is_removable_drive(dest))
|
|
|
|
msg << "Inserire un nuovo disco e ritentare?";
|
|
|
|
else
|
|
|
|
msg << "Liberare dello spazio e ritentare?";
|
|
|
|
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
|
|
|
|
{
|
|
|
|
if (!yesno_box("Errore di copia del file %s.\nSi desidera riprovare?",
|
|
|
|
(const char*)file))
|
|
|
|
user_abort = TRUE;
|
|
|
|
}
|
|
|
|
} while (!write_ok && !user_abort);
|
|
|
|
|
|
|
|
return write_ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
message_box("Inserire il disco 1 nel drive %c:", floppy);
|
|
|
|
size = os_get_disk_size(path) - (64L*1024L);
|
|
|
|
if (size <= 0)
|
|
|
|
{
|
|
|
|
if (!yesno_box("Errore di accesso al drive %c\nSi desidera ritentare?", floppy))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
do_events();
|
|
|
|
}
|
|
|
|
|
|
|
|
const long minsize = 360*1024L;
|
|
|
|
if (size < minsize)
|
|
|
|
size = minsize;
|
|
|
|
|
|
|
|
// Costruisce percorso dello splitter
|
|
|
|
TFilename cmd("zipsplit.pif");
|
|
|
|
cmd << " -n " << (long)size << " -b " << archive.path() << ' ' << archive;
|
|
|
|
|
|
|
|
// Esegue lo splitter nella directory temporanea
|
|
|
|
TExternal_app app(cmd);
|
|
|
|
int err = app.run(FALSE, FALSE, FALSE, FALSE);
|
|
|
|
|
|
|
|
if (err != NOERR)
|
|
|
|
return error_box("Errore %d durante lo splitting del file %s",
|
|
|
|
err, (const char*)archive);
|
|
|
|
|
|
|
|
size = ::fsize(archive);
|
|
|
|
::remove(archive);
|
|
|
|
|
|
|
|
for (int d = 1; ; d++)
|
|
|
|
{
|
|
|
|
TFilename src(archive);
|
|
|
|
src.ext("");
|
|
|
|
src << d;
|
|
|
|
src.ext("zip");
|
|
|
|
if (src.exist())
|
|
|
|
{
|
|
|
|
if (d > 1)
|
|
|
|
{
|
|
|
|
message_box("Inserire il disco %d nel drive %c:", d, floppy);
|
|
|
|
do_events();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (move_file(src, path))
|
|
|
|
{
|
|
|
|
TFilename ini(path);
|
|
|
|
ini.add("backup.ini");
|
|
|
|
TConfig c(ini, archive.name());
|
|
|
|
c.set("Size", size);
|
|
|
|
c.set("Disk", d);
|
|
|
|
c.set("Description", desc);
|
|
|
|
c.set("Date", TDate(TODAY).string());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* const file[] = { "zip.pif", "zip386.bat", "zip386.exe", "ziplist.txt", NULL };
|
|
|
|
|
|
|
|
bool TArchive::copy_zipper(const char* dir) const
|
|
|
|
{
|
|
|
|
bool ok = TRUE;
|
|
|
|
TFilename dest;
|
|
|
|
for (int f = 0; ok && file[f]; f++)
|
|
|
|
{
|
|
|
|
dest = dir;
|
|
|
|
dest.add(file[f]);
|
|
|
|
ok &= ::fcopy(file[f], dest);
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TArchive::remove_zipper(const char* dir) const
|
|
|
|
{
|
|
|
|
TFilename dest;
|
|
|
|
for (int f = 0; file[f]; f++)
|
|
|
|
{
|
|
|
|
dest = dir;
|
|
|
|
dest.add(file[f]);
|
|
|
|
::remove(dest);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TArchive::add_zipper_list(TString& str) const
|
|
|
|
{
|
|
|
|
for (int f = 0; file[f]; f++)
|
|
|
|
str << ' ' << file[f];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @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.
|
|
|
|
|
|
|
|
{
|
|
|
|
const TString16 old(prefix().name());
|
|
|
|
prefix().set(NULL);
|
|
|
|
|
|
|
|
const TFilename workdir(dir);
|
|
|
|
|
|
|
|
TString16 name(workdir.name());
|
|
|
|
// Trasforma com in datcom altrimenti lo splitter lo trasforma in com1 e com2!
|
|
|
|
if (name.compare("com", -1, TRUE) == 0)
|
|
|
|
name = "datcom";
|
|
|
|
|
|
|
|
// Nome del file compresso
|
|
|
|
TFilename work; work.tempdir(); work.add(name); work.ext("zip");
|
|
|
|
|
|
|
|
TString title("Archiviazione di "); title << workdir;
|
|
|
|
TIndwin waitw(100,title,FALSE,FALSE);
|
|
|
|
TWait_cursor hourglass;
|
|
|
|
|
|
|
|
// Crea il file con la lista dei file da comprimere
|
|
|
|
const char* const ZIPLIST = "ziplist.txt";
|
|
|
|
FILE* flist = fopen(ZIPLIST, "w");
|
|
|
|
fprintf(flist, "*.*");
|
|
|
|
fclose(flist);
|
|
|
|
|
|
|
|
copy_zipper(workdir);
|
|
|
|
|
|
|
|
// Esegui lo zippatore
|
|
|
|
TFilename cmd = workdir;
|
|
|
|
cmd.add("zip.pif");
|
|
|
|
cmd << ' ' << work << ' ' << ZIPLIST << " -D -r";
|
|
|
|
|
|
|
|
TExternal_app zipapp(cmd);
|
|
|
|
int err = zipapp.run(FALSE, FALSE, FALSE, FALSE);
|
|
|
|
|
|
|
|
// Elimina files temporanei dallo zip
|
|
|
|
/*
|
|
|
|
cmd = workdir;
|
|
|
|
cmd.add("zip386.exe");
|
|
|
|
cmd << ' ' << work << " -d";
|
|
|
|
add_zipper_list(cmd);
|
|
|
|
TExternal_app zipdel(cmd);
|
|
|
|
zipdel.run(FALSE, FALSE, FALSE, FALSE);
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Elimina i file temporanei dalla directory
|
|
|
|
remove_zipper(workdir);
|
|
|
|
|
|
|
|
// Splitta su floppy
|
|
|
|
bool ok = err == 0;
|
|
|
|
if (ok)
|
|
|
|
ok = fsplit_zip(work, floppy, desc);
|
|
|
|
else
|
|
|
|
error_box("Compressione degli archivi errata o incompleta");
|
|
|
|
|
|
|
|
prefix().set(old);
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TArchive::zip(long firm, char floppy, const char* desc)
|
|
|
|
{
|
|
|
|
TString_array fl;
|
|
|
|
const int num_ditte = build_backup_list(firm, fl);
|
|
|
|
|
|
|
|
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
|
|
|
|
char floppy, // @parm Floppy da cui leggere i dati
|
|
|
|
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();
|
|
|
|
if (output.compare("com", -1, TRUE) == 0)
|
|
|
|
output = "datcom";
|
|
|
|
output.ext("zip");
|
|
|
|
|
|
|
|
if (!yesno_box("Attenzione l'archivio %c:%s verra' ripristinato\n"
|
|
|
|
"nel direttorio %s. Continuare?",
|
|
|
|
floppy, (const char*)output, (const char*)work))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
bool ok = work.exist();
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
ok = yesno_box("Non esiste il direttorio %s: si desidera crearlo?", (const char*)work);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
make_dir(work);
|
|
|
|
ok = work.exist();
|
|
|
|
}
|
|
|
|
if (!ok)
|
|
|
|
return error_box("Impossibile accedere a %s", (const char*)work);
|
|
|
|
}
|
|
|
|
|
|
|
|
TString title("Ripristino di "); title << output;
|
|
|
|
TIndwin waitw(100,title,FALSE,FALSE);
|
|
|
|
|
|
|
|
const TString16 old(prefix().name());
|
|
|
|
prefix().set(NULL);
|
|
|
|
|
|
|
|
TFilename cfg;
|
|
|
|
cfg << floppy << ':';
|
|
|
|
cfg.add("backup.ini");
|
|
|
|
TConfig c(cfg, output.name());
|
|
|
|
long total_size = c.get_long("Size");
|
|
|
|
long read_size = 0;
|
|
|
|
for (int d = 1; read_size < total_size; d++)
|
|
|
|
{
|
|
|
|
TFilename src;
|
|
|
|
src << floppy << ':' << SLASH << output.name();
|
|
|
|
src.ext("");
|
|
|
|
src << d << ".zip";
|
|
|
|
|
|
|
|
message_box("Inserire il disco %d contenente il file %s", d, (const char*)src);
|
|
|
|
while (!src.exist())
|
|
|
|
{
|
|
|
|
if (!yesno_box("Impossibile aprire il file %s:\nSi desidera ritentare?",
|
|
|
|
(const char *)src))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src.exist())
|
|
|
|
{
|
|
|
|
TFilename cmd;
|
|
|
|
cmd << "unzip.pif -o " << src << " -d " << work;
|
|
|
|
TExternal_app app(cmd);
|
|
|
|
int err = app.run(FALSE, FALSE, FALSE, FALSE);
|
|
|
|
if (err == 0)
|
|
|
|
read_size += ::fsize(src);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error_box("Errore %d durante il ripristino del file %s", err, (const char*)src);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefix().set(old);
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
1995-09-11 15:13:50 +00:00
|
|
|
|
1998-04-30 14:54:04 +00:00
|
|
|
bool TArchive::unzip(long firm, char floppy, bool temp)
|
|
|
|
{
|
|
|
|
TString_array fl;
|
|
|
|
const int num_ditte = build_restore_list(firm, floppy, fl);
|
|
|
|
|
|
|
|
bool ok = TRUE;
|
|
|
|
for (int f = 0; f < num_ditte; f++)
|
|
|
|
{
|
|
|
|
ok = unzip(fl.row(f), floppy, temp);
|
|
|
|
if (!ok) break;
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|