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(""); prefhndl->set("");
dir.get(i, _nolock, _nordir, _sysdirop); dir.get(i, _nolock, _nordir, _sysdirop);
rec.get(i); rec.get(i);
bool create_now = dir.is_active();
prefhndl->set_codditta(codditta); prefhndl->set_codditta(codditta);
dir.put(i, _nordir, _sysdirop); dir.put(i, _nordir, _sysdirop);
rec.put(i); rec.put(i);
const char* name = dir.name(); const char* name = dir.name();
dir.flags() = 0L; dir.flags() = 0L;
const bool valid_file = *name > ' ' && dir.len() > 0; create_now = create_now && (flagcom ? dir.is_com() : dir.is_firm());
const bool create_now = flagcom ? *name == '%' : *name != '%';
if (valid_file && create_now) if (dir.is_valid() && create_now)
{ {
TSystemisamfile f(i); TSystemisamfile f(i);
f.build(30); f.build(30);
} }
else else
{ {
if (!flagcom) // if (!flagcom)
{ // {
dir.len() = 0; // dir.len() = 0;
rec.zero(); // rec.zero();
} // }
dir.put(i, _nordir, _sysdirop); dir.put(i, _nordir, _sysdirop);
rec.put(i); rec.put(i);
} }

View File

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

View File

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

View File

@ -57,6 +57,7 @@ class TDir : public TObject
// @DPRIV // @DPRIV
FileDes* _dir; FileDes* _dir;
int _num; int _num;
bool _com;
public: public:
// @FPUB // @FPUB
@ -79,6 +80,10 @@ public:
int num() const { return _num;} int num() const { return _num;}
int items(TDirtype dirtype = _nordir) const; int items(TDirtype dirtype = _nordir) const;
FileDes* filedesc() const { return _dir; } 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(); TDir();
virtual ~TDir(); virtual ~TDir();

View File

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

View File

@ -45,6 +45,8 @@ public:
int items() const { return _items; } int items() const { return _items; }
const char* description(const char* cod) const; const char* description(const char* cod) const;
const char* description(int 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(); TPrefix();
virtual ~TPrefix(); virtual ~TPrefix();