Aggiunti metodi per stabilire il tipo di file (comune o ditta)

git-svn-id: svn://10.65.10.50/trunk@955 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1995-02-02 18:08:50 +00:00
parent f14e63a20c
commit b4c36428d8
6 changed files with 92 additions and 113 deletions

View File

@ -217,26 +217,27 @@ bool TMenu_application::build_firm_data(long codditta, bool flagcom)
prefhndl->set("");
dir.get(i, _nolock, _nordir, _sysdirop);
rec.get(i);
bool create_now = dir.is_active();
prefhndl->set_codditta(codditta);
dir.put(i, _nordir, _sysdirop);
rec.put(i);
const char* name = dir.name();
dir.flags() = 0L;
const bool valid_file = *name > ' ' && dir.len() > 0;
const bool create_now = flagcom ? *name == '%' : *name != '%';
create_now = create_now && (flagcom ? dir.is_com() : dir.is_firm());
if (valid_file && create_now)
if (dir.is_valid() && create_now)
{
TSystemisamfile f(i);
f.build(30);
}
else
{
if (!flagcom)
{
dir.len() = 0;
rec.zero();
}
// if (!flagcom)
// {
// dir.len() = 0;
// rec.zero();
// }
dir.put(i, _nordir, _sysdirop);
rec.put(i);
}

View File

@ -54,43 +54,43 @@ M 8 0
M
M
M)&EN9'-P960N9'1A
M #J /____]);F1I<FEZ>FD@9&D@<W!E9&EZ:6]N90
M #J < !);F1I<FEZ>FD@9&D@<W!E9&EZ:6]N90
M !.0T8
M )&-F=F5N+F1T80
M 9 ?____]#;&EE;G1I
M 9 0< !#;&EE;G1I
M+T9O<FYI=&]R:2!P97(@=F5N9&ET90 !.0T8
M
M )&]C8V%S+F1T80
M "6 !#;&EE;G1I(&]C8V%S:6]N86QI
M "6 < !#;&EE;G1I(&]C8V%S:6]N86QI
M Q,#
M )'!C;VXN9'1A
M !J
M !J <
M !0:6%N;R!D96D@8V]N=&D !.
M0T].
M )&-L:69O+F1T80
M #Y 0 !#;&EE;G1I+T9O<FYI=&]R
M #Y 0< !#;&EE;G1I+T9O<FYI=&]R
M:0 !.0T8
M
M)'-A;&1I+F1T80
M "? !386QD:0
M "? < !386QD:0
M !.0T8K3D-/3@
M )&%L;&5G+F1T80
M #@ !0<F]G<F5S
M #@ < !0<F]G<F5S
M<VEV:2!A;&QE9V%T:2!)5D$ !.0T8
M
M )&UO=BYD=&$
M ? 0 !-;W9I;65N=&D@9&D@<')I;6$@;F]T80
M ? 0< !-;W9I;65N=&D@9&D@<')I;6$@;F]T80
M !.34]6
M )')M;W8N9'1A
M "!
M "! <
M !2:6=H92!D:2!M;W9I;65N=&\@8V]N=&%B:6QE !.
M34]6*C,
M )')M;W9I=F$N9'1A
M !. !2:6=H92!M;W9I;65N=&\@
M !. < !2:6=H92!M;W9I;65N=&\@
M259! !.34]6*C(
M
M)&-A=7,N9'1A
M !, !#875S86QI(&-O;G1A8FEL:0
M !, < !#875S86QI(&-O;G1A8FEL:0
M V,
M )')C875S+F1T80
M !1 !2:6=H92!C

View File

@ -12,15 +12,25 @@
#include <extcdecl.h>
#endif
#ifndef __APPLICAT_H
#include <applicat.h>
#endif
#ifndef __STRINGS_H
#include <strings.h>
#endif
#ifndef __UTILITY_H
#include <utility.h>
#endif
#define BLOCKLEN 512
#define INVFLD 255
HIDDEN char _files_tmp_string[128];
TFile ::TFile (int lenrec, int base)
TFile::TFile (int lenrec, int base)
{
_file = new SecDef;
@ -34,57 +44,50 @@ TFile ::TFile (int lenrec, int base)
_file->name[0] = '\0';
}
TFile ::~TFile ()
TFile::~TFile ()
{
delete _file;
}
void TFile ::
open (const char *name, TFilelock lockmode)
void TFile::open (const char *name, TFilelock lockmode)
{
COpen (_file, (char *) name, _len, _base, lockmode);
}
bool TFile ::
verify (const char *name)
bool TFile::verify (const char *name)
{
CVerify (_file, (char *) name);
return _file->IOR == NOERR;
}
void TFile ::
create (const char *name, TRecnotype nrecord)
void TFile::create (const char *name, TRecnotype nrecord)
{
CCreate (_file, (char *) name, _len, _base, (nrecord * _len) / BLOCKLEN + 1);
}
void TFile ::
chsize (const char *name, TRecnotype nrecord)
void TFile::chsize (const char *name, TRecnotype nrecord)
{
CChsize (_file, (char *) name, _len, _base, (nrecord * _len) / BLOCKLEN + 1);
}
void TFile ::
close ()
void TFile::close ()
{
CClose (_file);
}
void TFile ::
unlink (const char *name)
void TFile::unlink (const char *name)
{
CDelete (_file, (char *) name);
}
void TFile ::
read (char *record, TRecnotype recnum, TReclock lock)
void TFile::read (char *record, TRecnotype recnum, TReclock lock)
{
_file->LenRec = _len;
@ -92,8 +95,7 @@ read (char *record, TRecnotype recnum, TReclock lock)
CRead (_file, record, recnum, lock);
}
void TFile ::
write (char *record, TRecnotype recnum, TReclock lock)
void TFile::write (char *record, TRecnotype recnum, TReclock lock)
{
_file->LenRec = _len;
@ -101,105 +103,86 @@ write (char *record, TRecnotype recnum, TReclock lock)
CWrite (_file, record, recnum, lock);
}
int TFile ::
status ()
const
int TFile::status () const
{
return _file->IOR;
}
TDir ::
TDir ()
TDir::TDir () : _num(-1), _com(FALSE)
{
_dir = new FileDes;
if (_dir == NULL)
fatal_box ("Can't allocate dir");
zero ();
_num = -1;
}
TDir ::~TDir ()
TDir::~TDir ()
{
delete _dir;
}
const char *TDir ::
name ()
const
const char *TDir::name () const
{
return _dir->SysName;
}
const char *TDir ::des ()
const
const char *TDir::des () const
{
return _dir->Des;
}
const char *TDir ::expr ()
const
const char *TDir::expr () const
{
return _dir->FCalc;
}
TRecnotype & TDir ::
eod ()
const
TRecnotype & TDir::eod () const
{
return _dir->EOD;
}
TRecnotype & TDir ::
eox ()
const
TRecnotype & TDir::eox () const
{
return _dir->EOX;
}
TRecnotype & TDir ::
flags ()
const
TRecnotype & TDir::flags () const
{
return _dir->Flags;
}
word & TDir ::
len ()
word & TDir::len ()
{
return (word &) _dir->LenR;
}
int TDir ::
status (TDirtype dirop)
const
int TDir::status (TDirtype dirop) const
{
return fdir[dirop].IOR;
}
void TDir ::set_len (const UINT16 len)
void TDir::set_len (const UINT16 len)
{
_dir->LenR = len;
}
void TDir ::
set_eox (const RecNoType eox)
void TDir::set_eox (const RecNoType eox)
{
_dir->EOX = eox;
}
void TDir ::
set (const char *name, const RecNoType eod, const RecNoType flag, const char *des, const char *calc)
void TDir::set (const char *name, const RecNoType eod, const RecNoType flag, const char *des, const char *calc)
{
strncpy (_dir->SysName, name, sizeof (_dir->SysName));
_dir->EOD = eod;
@ -208,8 +191,7 @@ set (const char *name, const RecNoType eod, const RecNoType flag, const char *de
strncpy (_dir->FCalc, calc, sizeof (_dir->FCalc));
}
void TDir ::
get (int nfile, TReclock lock, TDirtype dirtype, TDirop op)
void TDir::get (int nfile, TReclock lock, TDirtype dirtype, TDirop op)
{
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
@ -219,10 +201,10 @@ get (int nfile, TReclock lock, TDirtype dirtype, TDirop op)
else
CGetFile (nfile, _dir, int (lock), _whichdir);
_num = nfile;
_com = _dir->SysName[0] != '$';
}
void TDir ::
put (int nfile, TDirtype dirtype, TDirop op)
void TDir::put (int nfile, TDirtype dirtype, TDirop op)
{
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
@ -235,16 +217,13 @@ put (int nfile, TDirtype dirtype, TDirop op)
CPutFile (nfile, _dir, _whichdir);
}
void TDir ::
zero ()
void TDir::zero ()
{
zerofdes (_dir);
}
int TDir ::
items (TDirtype dirtype)
const
int TDir::items (TDirtype dirtype) const
{
FileDes f;
@ -254,8 +233,15 @@ items (TDirtype dirtype)
return (int) f.EOD;
}
TTrec ::
TTrec ()
bool TDir::is_active () const
{
int module = (int) flags();
if (module < 0) module = -module;
return main_app().has_module(module, CHK_DONGLE);
}
TTrec::TTrec ()
{
_rec = new RecDes;
@ -265,15 +251,13 @@ TTrec ()
_num = -1;
}
TTrec ::~TTrec ()
TTrec::~TTrec ()
{
delete _rec;
}
int TTrec ::
compare (const TSortable & a)
const
int TTrec ::compare (const TSortable & a) const
{
const TTrec & r = (const TTrec &) a;
@ -281,13 +265,13 @@ compare (const TSortable & a)
return res;
}
void TTrec ::rehash ()
void TTrec::rehash ()
{
setrdes (_rec);
}
TTrec & TTrec ::operator = (const TTrec & b)
TTrec & TTrec::operator = (const TTrec & b)
{
_num = b._num;
@ -295,8 +279,7 @@ TTrec & TTrec ::operator = (const TTrec & b)
return *this;
}
void TTrec ::
get (int nfile, TDirtype dirtype)
void TTrec::get (int nfile, TDirtype dirtype)
{
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
@ -305,8 +288,7 @@ get (int nfile, TDirtype dirtype)
_num = nfile;
}
void TTrec ::
put (int nfile, TDirtype dirtype)
void TTrec::put (int nfile, TDirtype dirtype)
{
int _whichdir = (dirtype == _nordir ? NORDIR : COMDIR);
@ -316,31 +298,26 @@ put (int nfile, TDirtype dirtype)
CPutRec (nfile, _rec, _whichdir);
}
void TTrec ::
zero ()
void TTrec::zero ()
{
zerordes (_rec);
}
int TTrec ::
status (TDirtype dirop)
const
int TTrec::status (TDirtype dirop) const
{
return rdir[dirop].IOR;
}
int TTrec ::field (const char *name)
const
int TTrec ::field (const char *name) const
{
return findfld (_rec, (char *) name);
}
const char *TTrec ::fielddef (int fld)
const
const char *TTrec ::fielddef (int fld) const
{
sprintf (_files_tmp_string, "%s|%d|%d|%d", _rec->Fd[fld].Name,
@ -349,8 +326,7 @@ const char *TTrec ::fielddef (int fld)
return _files_tmp_string;
}
const char *TTrec ::keydef (int key)
const
const char *TTrec ::keydef (int key) const
{
TFixed_string s (_files_tmp_string, 128);
@ -379,8 +355,7 @@ const char *TTrec ::keydef (int key)
#ifndef FOXPRO
void TTrec ::
update_fielddef (int nfld, const char *desc)
void TTrec::update_fielddef (int nfld, const char *desc)
{
TToken_string s (desc);
@ -390,8 +365,7 @@ update_fielddef (int nfld, const char *desc)
_rec->Fd[nfld].Dec = s.get_int ();
}
void TTrec ::
update_keydef (int key, const char *desc)
void TTrec::update_keydef (int key, const char *desc)
{
TExpression expr ("", _strexpr);
@ -440,9 +414,7 @@ update_keydef (int key, const char *desc)
}
}
void TTrec ::
print_on (ostream & out)
const
void TTrec::print_on (ostream & out) const
{
out << num () << '\n';
@ -465,8 +437,7 @@ print_on (ostream & out)
}
}
void TTrec ::
read_from (istream & in)
void TTrec::read_from (istream & in)
{
int ln;

View File

@ -57,6 +57,7 @@ class TDir : public TObject
// @DPRIV
FileDes* _dir;
int _num;
bool _com;
public:
// @FPUB
@ -79,6 +80,10 @@ public:
int num() const { return _num;}
int items(TDirtype dirtype = _nordir) const;
FileDes* filedesc() const { return _dir; }
bool is_com() const {return _com;} // valido solo se la get e' stata effettuata con _sysdirop
bool is_firm() const {return !_com;} // valido solo se la get e' stata effettuata con _sysdirop
bool is_valid() {return name()[0] > ' ' && len() > 0;}
bool is_active() const; // valido solo se prefhnd e settato a ""
TDir();
virtual ~TDir();

View File

@ -961,8 +961,8 @@ int TSystemisamfile::update(TTrec& newrec, bool vis)
dir.get(num(), _lock, _nordir, _sysdirop);
const char p = *dir.name();
const bool incom = strcmp(prefhndl->name(), "com") == 0;
const bool toconvert = (incom ? p == '%' : p != '%');
const bool is_com = prefhndl->is_com();
const bool toconvert = is_com ? dir.is_com() : dir.is_firm();
int err = NOERR;
TTrec oldrec;

View File

@ -45,6 +45,8 @@ public:
int items() const { return _items; }
const char* description(const char* cod) const;
const char* description(int cod) const;
bool is_firm() const { return _prefix.len() == 6 && _prefix[5] == 'a';}
bool is_com() const { return !is_firm();}
TPrefix();
virtual ~TPrefix();