Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : msksheet.cpp Tolto spazio inutile os_win32.cpp Corretto calcolo spazio libero su disco prefix.* Aggiunto clock_t di ultima modifica al file recarray.* Aggiunta discard relation.* Corretti alcuni metodi TSorted_file git-svn-id: svn://10.65.10.50/trunk@7201 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
1efdf8ef16
commit
5657e8ae59
@ -2648,7 +2648,7 @@ void TSheet_field::mask2row(int n, TToken_string & rec)
|
||||
|
||||
|
||||
// Ricopia i campi del record dato nella maschera
|
||||
void TSheet_field::row2mask(int n, TToken_string & r, int mode)
|
||||
void TSheet_field::row2mask(int n, TToken_string& r, int mode)
|
||||
{
|
||||
TString val(80);
|
||||
|
||||
|
@ -183,11 +183,19 @@ bool os_test_disk_free_space(const char* path, unsigned long filesize)
|
||||
|
||||
// On Win95 may fail for disks > 2GB
|
||||
DWORD nSecPerClust, nBytePerSec, nFreeClust;
|
||||
GetDiskFreeSpace(path, &nSecPerClust, &nBytePerSec, &nFreeClust, NULL);
|
||||
__int64 nFree = nFreeClust;
|
||||
nFree *= nSecPerClust;
|
||||
nFree *= nBytePerSec;
|
||||
return nFree > filesize;
|
||||
bool ok = GetDiskFreeSpace(path, &nSecPerClust, &nBytePerSec, &nFreeClust, NULL) != 0;
|
||||
|
||||
if (ok && nBytePerSec >= 512)
|
||||
{
|
||||
__int64 nFree = nFreeClust;
|
||||
nFree *= nSecPerClust;
|
||||
nFree *= nBytePerSec;
|
||||
ok = nFree > filesize;
|
||||
}
|
||||
else
|
||||
ok = TRUE;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
unsigned long os_get_disk_size(const char* path)
|
||||
|
@ -235,7 +235,7 @@ class TFile_info : public TObject
|
||||
|
||||
int _num;
|
||||
int _handle;
|
||||
clock_t _last_access;
|
||||
clock_t _last_access, _last_change;
|
||||
bool _locked, _exclusive;
|
||||
TDirtype _dir;
|
||||
FileDes _filedes;
|
||||
@ -255,11 +255,13 @@ public:
|
||||
int handle() const { return _handle; }
|
||||
bool is_open() const { return _handle >= 0; }
|
||||
clock_t last_access() const { return _last_access; }
|
||||
clock_t last_change() const { return _last_change; }
|
||||
bool is_exclusive() const { return _exclusive; }
|
||||
bool is_locked() const { return _locked; }
|
||||
int ref_count() const { return _ref_count; }
|
||||
int last_key() const { return _last_key; }
|
||||
void touch() { _last_access = clock(); }
|
||||
void set_dirty() { _last_change = clock(); }
|
||||
|
||||
TDirtype dir_type() const { return _dir; }
|
||||
bool mutable_dir() const { return _dir <= _studir; }
|
||||
@ -436,7 +438,7 @@ const TFilename& TFile_info::load_filedes()
|
||||
TFile_info::TFile_info(int logicnum, TFilename& name)
|
||||
: _num(logicnum), _handle(-1), _ref_count(0),
|
||||
_locked(FALSE), _exclusive(FALSE),
|
||||
_last_access(0), _last_key(-1)
|
||||
_last_access(0), _last_change(0), _last_key(-1)
|
||||
{
|
||||
if (logicnum < LF_EXTERNAL)
|
||||
{
|
||||
@ -477,14 +479,12 @@ TFile_info::TFile_info(int logicnum, TFilename& name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TFile_info::~TFile_info()
|
||||
{
|
||||
if (is_open())
|
||||
close_low();
|
||||
}
|
||||
|
||||
|
||||
TFile_info& TFile_manager::fileinfo(TIsam_handle num) const
|
||||
{
|
||||
TFile_info* i = (TFile_info*)_fileinfo.objptr(num);
|
||||
@ -688,6 +688,18 @@ TDirtype TFile_manager::get_dirtype(int logicnum)
|
||||
return i.dir_type();
|
||||
}
|
||||
|
||||
void TFile_manager::notify_change(TIsam_handle name)
|
||||
{
|
||||
TFile_info& i = fileinfo(name);
|
||||
i.set_dirty();
|
||||
}
|
||||
|
||||
long TFile_manager::last_change(TIsam_handle name) const
|
||||
{
|
||||
TFile_info& i = fileinfo(name);
|
||||
return i.last_change();
|
||||
}
|
||||
|
||||
int TFile_manager::close_closeable()
|
||||
{
|
||||
_open_files = 0;
|
||||
@ -1040,6 +1052,14 @@ const char* firm2dir(
|
||||
return __tmp_string;
|
||||
}
|
||||
|
||||
int safely_close_closeable_isamfiles()
|
||||
{
|
||||
int f = 0;
|
||||
if (_prefhndl)
|
||||
f = _prefhndl->close_closeable_isamfiles();
|
||||
return f;
|
||||
}
|
||||
|
||||
bool TPrefix::build_firm_data(long codditta, bool flagcom)
|
||||
{
|
||||
const char * const ndir = "/dir.gen";
|
||||
@ -1137,7 +1157,6 @@ bool TPrefix::build_firm_data(long codditta, bool flagcom)
|
||||
}
|
||||
|
||||
TConfig c(CONFIG_STUDIO, "cg");
|
||||
|
||||
if (c.get_bool("StiReg"))
|
||||
{
|
||||
TTable reg("REG");
|
||||
|
@ -49,6 +49,9 @@ public:
|
||||
TCodeb_handle get_handle(TIsam_handle name, int key);
|
||||
int get_reclen(int logicnum);
|
||||
|
||||
void notify_change(TIsam_handle name);
|
||||
long last_change(TIsam_handle name) const;
|
||||
|
||||
int close_closeable();
|
||||
void close_all();
|
||||
void open_all();
|
||||
@ -162,6 +165,12 @@ public:
|
||||
const TFilename& get_filename(TIsam_handle name) const
|
||||
{ return _manager.get_filename(name); }
|
||||
|
||||
void notify_change(TIsam_handle name)
|
||||
{ _manager.notify_change(name); }
|
||||
|
||||
long last_change(TIsam_handle name) const
|
||||
{ return _manager.last_change(name); }
|
||||
|
||||
// @cmember Costruttore
|
||||
TPrefix();
|
||||
// @cmember Distruttore
|
||||
@ -170,6 +179,7 @@ public:
|
||||
|
||||
|
||||
const char* firm2dir(long codditta);
|
||||
int safely_close_closeable_isamfiles();
|
||||
|
||||
TPrefix& prefix_init();
|
||||
bool prefix_valid();
|
||||
|
@ -427,9 +427,12 @@ TFile_cache::~TFile_cache()
|
||||
|
||||
void TFile_cache::init_file(TLocalisamfile* f)
|
||||
{
|
||||
if (_file != NULL)
|
||||
if (_file != NULL)
|
||||
{
|
||||
delete _file;
|
||||
|
||||
_file = NULL;
|
||||
}
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
int logicnum = atoi(_filecode);
|
||||
@ -519,6 +522,14 @@ const TObject& TFile_cache::query(const char* code)
|
||||
return *obj;
|
||||
}
|
||||
|
||||
bool TFile_cache::discard(const char* victim)
|
||||
{
|
||||
if (victim && *victim)
|
||||
return _cache.remove(victim);
|
||||
destroy();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int TFile_cache::io_result()
|
||||
{
|
||||
return _error;
|
||||
|
@ -164,6 +164,8 @@ protected:
|
||||
TLocalisamfile & file();
|
||||
|
||||
public:
|
||||
virtual bool discard(const char* victim);
|
||||
|
||||
int io_result();
|
||||
const int key_number() const
|
||||
{ return _key; }
|
||||
|
@ -1425,7 +1425,8 @@ TRecnotype TCursor::operator +=(const TRecnotype npos)
|
||||
_totrec = update();
|
||||
|
||||
_pos += npos;
|
||||
if (_pos > _totrec) _pos = _totrec;
|
||||
if (_pos > _totrec)
|
||||
_pos = _totrec;
|
||||
else
|
||||
if (_pos < 0) _pos = 0;
|
||||
readrec();
|
||||
@ -2336,16 +2337,26 @@ TRelation_description::~TRelation_description()
|
||||
// @mfunc Avanza di <p npos> record
|
||||
int TSortedfile::operator +=(const TRecnotype npos)
|
||||
{
|
||||
*_curs+=npos;
|
||||
setstatus(_curs->file().status());
|
||||
return _curs->test();
|
||||
int err = NOERR;
|
||||
TRecnotype p = _curs->pos() + npos;
|
||||
if (p < 0)
|
||||
{
|
||||
p = 0;
|
||||
err = _isbof;
|
||||
}
|
||||
if (p >= _curs->items())
|
||||
{
|
||||
err = _iseof;
|
||||
p = _curs->items();
|
||||
}
|
||||
*_curs = p;
|
||||
setstatus(err);
|
||||
return err;
|
||||
}
|
||||
// @mfunc Sposta indietro di <p npos> record
|
||||
int TSortedfile::operator -=(const TRecnotype npos)
|
||||
{
|
||||
*_curs-=npos;
|
||||
setstatus(_curs->file().status());
|
||||
return _curs->test();
|
||||
return operator+=(-npos);
|
||||
}
|
||||
// @mfunc Avanza al record successivo
|
||||
int TSortedfile::operator ++()
|
||||
@ -2361,30 +2372,35 @@ int TSortedfile::operator --()
|
||||
// @mfunc Si posiziona sul primo record del file (vedi <t TReclock>)
|
||||
int TSortedfile::first(word lockop )
|
||||
{
|
||||
_curs->first_item();
|
||||
setstatus(_curs->file().status());
|
||||
return _curs->items()>0;
|
||||
int err = _curs->items() > 0 ? NOERR : _iseof;
|
||||
*_curs = 0;
|
||||
setstatus(err);
|
||||
return err;
|
||||
}
|
||||
// @mfunc Si posiziona sull'ultimo record del file (vedi <t TReclock>)
|
||||
int TSortedfile::last(word lockop )
|
||||
{
|
||||
int err = _curs->items() > 0 ? NOERR : _iseof;
|
||||
_curs->last_item();
|
||||
setstatus(_curs->file().status());
|
||||
return _curs->items()>0;
|
||||
setstatus(err);
|
||||
return err;
|
||||
}
|
||||
// @mfunc Si posiziona sul successivo record del file (vedi <t TReclock>)
|
||||
int TSortedfile::next(word lockop )
|
||||
{
|
||||
_curs->succ_item();
|
||||
setstatus(_curs->file().status());
|
||||
return _curs->pos()<=_curs->items();
|
||||
int err = _curs->pos() < _curs->items() ? NOERR : _iseof;
|
||||
setstatus(err);
|
||||
return err;
|
||||
}
|
||||
// @mfunc Si posiziona sul precedente record del file (vedi <t TReclock>)
|
||||
int TSortedfile::prev(word lockop )
|
||||
{
|
||||
_curs->pred_item();
|
||||
setstatus(_curs->file().status());
|
||||
return _curs->pos()>0;
|
||||
int err = _curs->pos() > 0 ? NOERR : _isbof;
|
||||
if (err == NOERR)
|
||||
_curs->pred_item();
|
||||
setstatus(err);
|
||||
return err;
|
||||
}
|
||||
|
||||
// @mfunc Salta <p nrec> record dalla posizione corrente (vedi <t TReclock>)
|
||||
@ -2392,7 +2408,7 @@ int TSortedfile::skip(TRecnotype nrec, word lockop )
|
||||
{
|
||||
// return *this+=nrec; manca il lock...
|
||||
setstatus(_curs->file().status());
|
||||
error_box("Operazione 'skip' non consentita sul cursore");
|
||||
NFCHECK("Operazione 'skip' non consentita sul cursore");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2444,24 +2460,27 @@ int TSortedfile::readat(TRecnotype nrec, word lockop )
|
||||
}
|
||||
|
||||
// @mfunc Aggiunge un record
|
||||
int TSortedfile::write()
|
||||
int TSortedfile::write()
|
||||
{
|
||||
return write(curr());
|
||||
}
|
||||
// @mfunc Aggiunge un record copiando da <p rec>
|
||||
int TSortedfile::write(const TRectype& rec)
|
||||
{
|
||||
return 0;
|
||||
NFCHECK("Operazione 'write' non consentita sul TSortedfile");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// @mfunc Riscrive un record
|
||||
int TSortedfile::rewrite()
|
||||
{
|
||||
return 0;
|
||||
rewrite(curr());
|
||||
return 0;
|
||||
}
|
||||
// @mfunc Riscrive un record (il record <p rec>)
|
||||
int TSortedfile::rewrite(const TRectype& rec)
|
||||
{
|
||||
NFCHECK("Operazione 'rewrite' non consentita sul TSortedfile");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2473,7 +2492,7 @@ int TSortedfile::rewriteat(TRecnotype nrec)
|
||||
// @mfunc Riscrive un record alla posizione <p nrec> copiando da <p rec>
|
||||
int TSortedfile::rewriteat(const TRectype& rec, TRecnotype nrec)
|
||||
{
|
||||
error_box("Operazione 'rewriteat' non consentita sul cursore");
|
||||
NFCHECK("Operazione 'rewriteat' non consentita sul TSortedfile");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2485,6 +2504,7 @@ int TSortedfile::remove()
|
||||
// @mfunc Elimina il record copiando da <p rec>
|
||||
int TSortedfile::remove(const TRectype& rec)
|
||||
{
|
||||
NFCHECK("Operazione 'remove' non consentita sul TSortedfile");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2510,9 +2530,13 @@ bool TSortedfile::empty()
|
||||
return _curs->items()==0;
|
||||
}
|
||||
|
||||
TRectype& TSortedfile::curr() const
|
||||
{
|
||||
return _curs->curr();
|
||||
}
|
||||
|
||||
void TSortedfile::set_curr(TRectype * curr)
|
||||
{
|
||||
TLocalisamfile::set_curr(curr);
|
||||
_curs->file().set_curr(curr);
|
||||
}
|
||||
|
||||
@ -2521,26 +2545,25 @@ TSortedfile::TSortedfile(int logicnum,TRelation * rel,const char * ordexpr,const
|
||||
:TLocalisamfile(logicnum),_rel(NULL)
|
||||
{
|
||||
// costruisce il cursore
|
||||
if (!rel)
|
||||
{
|
||||
_rel = new TRelation(logicnum);
|
||||
}
|
||||
else
|
||||
_rel=rel;
|
||||
if (rel == NULL)
|
||||
rel = new TRelation(logicnum);
|
||||
|
||||
_rel=rel;
|
||||
_curs = new TSorted_cursor(_rel,ordexpr,"",nkey);
|
||||
|
||||
if (&curr()!=&(_curs->file().curr()))
|
||||
_curs->file().set_curr(&curr());
|
||||
// if (&curr()!=&(_curs->file().curr()))
|
||||
// _curs->file().set_curr(&curr());
|
||||
|
||||
_curs->setfilter(filter,TRUE); //must pass TRUE because cursors doesn't update rel (BUG).
|
||||
// DON't move this line BEFORE set_curr : filter's fieldrefs are allocated at cursor setfilter
|
||||
|
||||
|
||||
}
|
||||
// @mfunc Distruttore
|
||||
TSortedfile::~TSortedfile()
|
||||
{
|
||||
delete _curs;
|
||||
if (_rel) delete _rel;
|
||||
if (_rel)
|
||||
delete _rel;
|
||||
}
|
||||
|
||||
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
bool next_match(int logicnum, const char* fieldlist = NULL, int nkey = 0);
|
||||
|
||||
// @cmember Aggiunge una nuovo file alla relazione partendo dal descrittore del file
|
||||
bool add(TLocalisamfile* f, const char* relexprs, int key, int linkto, int alias, bool allow_lock);
|
||||
bool add(TLocalisamfile* f, const char* relexprs, int key = 1, int linkto = 0, int alias = 0, bool allow_lock = FALSE);
|
||||
// @cmember Aggiunge una nuovo file alla relazione partendo dal numero logico del file
|
||||
bool add(int logicnum, const char* relexprs, int key = 1, int linkto = 0, int alias = 0, bool allow_lock = FALSE);
|
||||
// @cmember Aggiunge una nuovo file alla relazione partendo dal nome della tabella
|
||||
@ -687,6 +687,8 @@ public:
|
||||
virtual bool tab() const
|
||||
{ return FALSE;}
|
||||
|
||||
// @cmember Ritorna il record corrente del del file
|
||||
virtual TRectype& curr() const;
|
||||
// @cmember Sostituisce il record corrente del del file (disallocando il vecchio)
|
||||
virtual void set_curr(TRectype * curr);
|
||||
// @cmember Si posiziona sul primo record del file (vedi <t TReclock>)
|
||||
@ -749,7 +751,7 @@ public:
|
||||
virtual bool is_sorted()
|
||||
{return TRUE;}
|
||||
// @cmember Costruttore.
|
||||
TSortedfile(int logicnum,TRelation * rel,const char * ordexpr="",const char * filter="", int nkey=1);
|
||||
TSortedfile(int logicnum,TRelation* rel = NULL,const char* ordexpr="",const char * filter="", int nkey=1);
|
||||
// @cmember Distruttore
|
||||
virtual ~TSortedfile();
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user