Meccanismo di protezione per i files sovrascritti
git-svn-id: svn://10.65.10.50/trunk@588 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8ca7b5aa46
commit
a69693ba65
@ -587,6 +587,52 @@ int TBaseisamfile::_open(unsigned int mode)
|
|||||||
_hfhd.len() = sizeof(TRecnotype);
|
_hfhd.len() = sizeof(TRecnotype);
|
||||||
_hfhd.base() = 0;
|
_hfhd.base() = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (err == NOERR)
|
||||||
|
{
|
||||||
|
isdef * fh = filehnd();
|
||||||
|
const TRecnotype nitems = fh->i.Base[0].PEOX;
|
||||||
|
|
||||||
|
if (fh->d->EOX != nitems)
|
||||||
|
{
|
||||||
|
CHECKD(getkey() == 1, "La chiave corrente non e' 1 ma ", getkey());
|
||||||
|
TFilename fn = filename();
|
||||||
|
|
||||||
|
fn = fn.name();
|
||||||
|
if (yesno_box("La dimensione dell' archivio %s e' errata. Cerco di recuperarlo ?", (const char *) fn))
|
||||||
|
{
|
||||||
|
TDir d;
|
||||||
|
TString mess(80);
|
||||||
|
{
|
||||||
|
mess.format("Ricostruzione archivio %s : I Fase", (const char*) fn);
|
||||||
|
TProgind p(nitems ? nitems : 1, mess, TRUE, TRUE, 70);
|
||||||
|
|
||||||
|
d.get(num(), _lock, _nordir, _sysdirop);
|
||||||
|
d.eod() = fh->d->EOD = nitems;
|
||||||
|
d.eox() = fh->d->EOX = nitems;
|
||||||
|
d.put(num(), _nordir, _sysdirop);
|
||||||
|
for (TRecnotype r = 1; r <= nitems; r++)
|
||||||
|
{
|
||||||
|
p.addstatus(1);
|
||||||
|
CRead(&fh->f, curr().string(), r, _nolock);
|
||||||
|
curr().discard();
|
||||||
|
CWrite(&fh->f, curr().string(), r, _nolock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mess.format("Ricostruzione archivio %s : II Fase", (const char*) fn);
|
||||||
|
TProgind p(items() ? items() : 1, mess, TRUE, TRUE, 70);
|
||||||
|
for (first(); good(); next())
|
||||||
|
{
|
||||||
|
p.addstatus(1);
|
||||||
|
curr().recall();
|
||||||
|
rewrite();
|
||||||
|
}
|
||||||
|
message_box("L'archivio %s deve essere compattato", (const char *) fn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fatal_box("L'archivio %s deve essere corretto prima di utilizzarlo", (const char *) fn);
|
||||||
|
}
|
||||||
|
}
|
||||||
_recno = -1L;
|
_recno = -1L;
|
||||||
_current->_i = filehnd();
|
_current->_i = filehnd();
|
||||||
setstatus(err);
|
setstatus(err);
|
||||||
@ -894,11 +940,13 @@ int TSystemisamfile::update(TTrec& newrec, bool vis)
|
|||||||
{
|
{
|
||||||
if (filehnd() != NULL)
|
if (filehnd() != NULL)
|
||||||
fatal_box("Can't update description for open file %s", filename());
|
fatal_box("Can't update description for open file %s", filename());
|
||||||
|
|
||||||
TDir dir;
|
TDir dir;
|
||||||
|
|
||||||
dir.get(num(), _lock, _nordir, _sysdirop);
|
dir.get(num(), _lock, _nordir, _sysdirop);
|
||||||
const char p = *dir.name();
|
const char p = *dir.name();
|
||||||
const bool toconvert = ((strcmp(prefhndl->name(), "com") == 0) ? p == '%' : p != '%');
|
const bool incom = strcmp(prefhndl->name(), "com") == 0;
|
||||||
|
const bool toconvert = (incom ? p == '%' : p != '%');
|
||||||
|
|
||||||
int err = NOERR;
|
int err = NOERR;
|
||||||
TTrec oldrec;
|
TTrec oldrec;
|
||||||
@ -907,8 +955,16 @@ int TSystemisamfile::update(TTrec& newrec, bool vis)
|
|||||||
const bool lcf = getlcf(prefhndl->filelevel());
|
const bool lcf = getlcf(prefhndl->filelevel());
|
||||||
|
|
||||||
if (!lcf && newrec == oldrec) return NOERR;
|
if (!lcf && newrec == oldrec) return NOERR;
|
||||||
|
|
||||||
const TRecnotype nitems = dir.eod();
|
const TRecnotype nitems = dir.eod();
|
||||||
const unsigned int lenr = newrec.len();
|
const unsigned int lenr = newrec.len();
|
||||||
|
|
||||||
|
if (!toconvert && dir.eox() > 0L)
|
||||||
|
{
|
||||||
|
dir.eod() = 0L;
|
||||||
|
dir.eox() = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
if (toconvert && dir.eox() > 0L)
|
if (toconvert && dir.eox() > 0L)
|
||||||
{
|
{
|
||||||
TRecnotype ni = 0L;
|
TRecnotype ni = 0L;
|
||||||
@ -1036,7 +1092,7 @@ int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
|
|||||||
f.equal();
|
f.equal();
|
||||||
const long level = atol(f.line());
|
const long level = atol(f.line());
|
||||||
if (level > stdlevel)
|
if (level > stdlevel)
|
||||||
error_box("L' archivio %s e' stato generato con gli archivi di livello %ld%/%ld.\n Il livello attuale e' %ld/%ld.\n Convertire gli archivi e ripetere l' operazione.", from, level / 100, level % 100, stdlevel / 100, stdlevel % 100);
|
error_box("L' archivio %s e' stato generato con gli archivi di livello %ld%/%ld.\\n Il livello attuale e' %ld/%ld.\\n Convertire gli archivi e ripetere l' operazione.", from, level / 100, level % 100, stdlevel / 100, stdlevel % 100);
|
||||||
lcf = getlcf(level);
|
lcf = getlcf(level);
|
||||||
nflds = 0;
|
nflds = 0;
|
||||||
TToken_string s2(f.line());
|
TToken_string s2(f.line());
|
||||||
@ -1079,20 +1135,22 @@ int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
|
|||||||
{
|
{
|
||||||
error_box("Formato dei dati non valido");
|
error_box("Formato dei dati non valido");
|
||||||
close();
|
close();
|
||||||
return 1;
|
err = 1;
|
||||||
|
setstatus(err);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd) sfd << fd;
|
if (fd) sfd << fd;
|
||||||
int last = NOERR;
|
int last = NOERR;
|
||||||
|
|
||||||
s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last);
|
s1.format("Imp. archivio %s\\n%6ld records %6ld errori - %3d", filename(), r, e, last);
|
||||||
TProgind p(nitems, s1, TRUE, TRUE, 70);
|
TProgind p(nitems, s1, TRUE, TRUE, 70);
|
||||||
s = f.line();
|
s = f.line();
|
||||||
while (s.not_empty() && !p.iscancelled())
|
while (s.not_empty() && !p.iscancelled())
|
||||||
{
|
{
|
||||||
if ((r + e) % 50 == 0)
|
if ((r + e) % 50 == 0)
|
||||||
{
|
{
|
||||||
s1.format("Imp. archivio %s\n%6ld rec. %6ld errori - %3d", filename(), r, e, last);
|
s1.format("Imp. archivio %s\\n%6ld records %6ld errori - %3d", filename(), r, e, last);
|
||||||
p.set_text(s1);
|
p.set_text(s1);
|
||||||
}
|
}
|
||||||
p.setstatus(nread + 1);
|
p.setstatus(nread + 1);
|
||||||
@ -1131,9 +1189,10 @@ int TSystemisamfile::load(const char* from, char fs, char fd, char rs, bool vis)
|
|||||||
}
|
}
|
||||||
s = f.line();
|
s = f.line();
|
||||||
}
|
}
|
||||||
s1.format("Imp. archivio %s : %6ld rec. %6ld errori - %3d", filename(), r, e, last);
|
s1.format("Imp. archivio %s\\n%6ld records %6ld errori - %3d", filename(), r, e, last);
|
||||||
p.set_text(s1);
|
p.set_text(s1);
|
||||||
close();
|
close();
|
||||||
|
setstatus(err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1213,6 +1272,7 @@ int TSystemisamfile::dump(const char* to, int nkey, char fs, char fd, char rs, b
|
|||||||
{
|
{
|
||||||
for (i = 0; i < nitems && !p.iscancelled(); i++)
|
for (i = 0; i < nitems && !p.iscancelled(); i++)
|
||||||
{
|
{
|
||||||
|
zero();
|
||||||
p.setstatus(i + 1);
|
p.setstatus(i + 1);
|
||||||
readat(i + 1);
|
readat(i + 1);
|
||||||
s="";
|
s="";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user