Merge branch 'R12.00.1136' of http://10.65.20.33/sirio/CAMPO/campo into R12.00.1136

This commit is contained in:
New_Macchina_Compilatrice 2022-08-04 00:45:47 +02:00
commit 87863c101b
11 changed files with 96 additions and 16 deletions

View File

@ -57,6 +57,7 @@ public:
bool TPackFiles_application::create() // initvar e arrmask
{
xvt_vobj_show(TASK_WIN);
_firm = get_firm();
if (!set_firm())
return false;

View File

@ -956,7 +956,7 @@ int TBaseisamfile::_write(const TRectype& rec)
if (rec.has_memo())
((TRectype&)rec).write_memo(_isam_handle, _recno );
rec_cache(_logicnum).notify_change();
xvt_fsys_set_file_time(filename(), nullptr, nullptr, xvt_time_now());
}
else
_lasterr = get_error(_lasterr);
@ -1016,6 +1016,7 @@ int TBaseisamfile::_rewrite(const TRectype& rec)
{
memcpy(DB_getrecord(fhnd), rec.string(), len);
_lasterr = DB_rewrite(fhnd);
xvt_fsys_set_file_time(filename(), nullptr, nullptr, xvt_time_now());
if (_lasterr == NOERR)
rec_cache(_logicnum).notify_change();
else
@ -3801,7 +3802,9 @@ const TString& TRectype::get(const char* fieldname) const
if (orig)
{
CHECKD(orig >= LF_EXTERNAL || orig == num(), "Invalid isam handle ", orig);
TCodeb_handle cb_handle = prefix().get_handle(orig, -1);
CHECKD(cb_handle >= 0, "Can't read memo from file ", orig);
if (DB_recno(cb_handle) != _memo_data->recno())
DB_go(cb_handle, _memo_data->recno());
@ -3910,7 +3913,7 @@ void TRectype::put_str(const char* fieldname, const char* val)
const int nf = findfld(&recd, fieldname);
if (nf == FIELDERR)
{
unknown_field(fieldname);
unknown_field(fieldname);
return;
}
@ -3937,6 +3940,7 @@ void TRectype::put_str(const char* fieldname, const char* val)
__putfieldbuff(fd.Len, fd.Dec, ft, val, _rec + fd.RecOff);
}
setempty(FALSE);
}
@ -3959,7 +3963,7 @@ void TRectype::zero(const char* fieldname)
const RecDes& recd = rec_des();
const int nf = findfld(&recd, fieldname);
if (nf == FIELDERR)
unknown_field(fieldname);
unknown_field(fieldname);
else
{
const int recoff = recd.Fd[nf].RecOff;
@ -3974,7 +3978,7 @@ void TRectype::zero(const char* fieldname)
__putfieldbuff(len, dec, _datefld, "", p);
break;
case _memofld:
__putfieldbuff(len, dec, _memofld, "", p);
__putfieldbuff(len, dec, _memofld, "", p);
_memo_data->add("", nf);
_memo_data->set_dirty(nf);
break;

View File

@ -94,7 +94,7 @@ void TRecord_array::set_key(TRectype* r)
const RecDes& recd = r->rec_des(); // Descrizione del record della testata
const KeyDes& kd = recd.Ky[0]; // Elenco dei campi della chiave 1
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
TString80 val;
for (int i = kd.NkFields-2; i >= 0; i--)
{
@ -546,6 +546,7 @@ int TRecord_array::remove() const
unsigned long TFile_cache::_hits = 0;
unsigned long TFile_cache::_misses = 0;
bool TFile_cache::_global_test_changes = false;
void TFile_cache::stats(unsigned long& h, unsigned long& m)
{
@ -661,11 +662,11 @@ void TFile_cache::test_firm()
}
}
if (_test_changes && !_changed && _file != NULL)
if (check_changes() && !_changed && _file != nullptr)
{
// Non controllare troppo spesso la data del file nei programmi batch: aspetta almeno 2 secondi!
const unsigned long now = clock();
if (now > _last_file_test + 2500)
if (now > _last_file_test + (_global_test_changes ? 0 : 2500))
{
TFilename n = prefix().get_filename(_file->num()); n.ext("dbf");
FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(n, &fs);
@ -677,7 +678,7 @@ void TFile_cache::test_firm()
}
}
const bool flush_needed = _test_changes && _changed && _file != NULL;
const bool flush_needed = check_changes() && _changed && _file != NULL;
if (flush_needed)
{
@ -720,7 +721,7 @@ const TObject& TFile_cache::query(const char* code)
TObject* obj = _cache.objptr(_code);
if (obj == NULL)
if (obj == nullptr)
{
TLocalisamfile& f = file();
TRectype& curr = f.curr();
@ -760,10 +761,7 @@ const TObject& TFile_cache::query(const char* code)
_misses++;
}
else
{
_hits++;
}
return *obj;
}

View File

@ -157,6 +157,7 @@ public:
class TFile_cache : public TObject
{
static unsigned long _hits, _misses;
static bool _global_test_changes;
TToken_string _code;
TString8 _filecode; // Codice tabella es: %STA, &AUT, LVCAU
@ -200,6 +201,8 @@ public:
void set_items_limit(long l) { _limit = l; }
void test_file_changes(bool t = TRUE) { _test_changes = t; }
static void global_file_changes(bool t = TRUE) { _global_test_changes = t; }
bool check_changes() const { return _global_test_changes || _test_changes; }
void notify_change();
static void stats(unsigned long& hits, unsigned long& misses);

View File

@ -214,6 +214,7 @@ void TRelation_application::set_find_button()
bool TRelation_application::create()
{
TFile_cache::global_file_changes(true);
bool ok = user_create();
if (ok)
{
@ -811,6 +812,7 @@ int TRelation_application::delete_mode()
TToken_string fldlist = brw->get_input_field_names();
TString80 str;
int fi = 0;
for (TString80 tok = inplist.get(fi); tok.not_empty(); tok = inplist.get(), fi++)
{
const TString16 fn = fldlist.get(fi);
@ -890,6 +892,7 @@ int TRelation_application::delete_mode()
TWait_cursor hourglass;
long skipped = 0; // Record non cancellati perche' protetti
cur.freeze(TRUE); // Congelo il cursore altrimenti si riaggiorna troppo
batch(true);
for (long pos = sht.items()-1; deleting > 0; pos--)
{
if (sht.checked(pos))
@ -919,7 +922,8 @@ int TRelation_application::delete_mode()
deleting--;
}
}
cur.freeze(false);
batch(false);
cur.freeze(false);
set_limits(); // Riaggiorno il numero del primo/ultimo record
if (skipped > 0)

View File

@ -63,6 +63,12 @@ void OsLinux_UpdateWindow(unsigned int handle)
// non deve fare nulla in Linux, sembra di si verificare SORRY_BOX();
}
void OsLinux_Set_FileTime(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime)
{
}
///////////////////////////////////////////////////////////
// Hardlock Support
///////////////////////////////////////////////////////////

View File

@ -6,6 +6,8 @@ int OsLinux_EnumerateSizes(const char* name, long* sizes, short* scalable, int m
void OsLinux_PlaceProcessInWindow(unsigned int instance, const char* name, unsigned int parent);
void OsLinux_UpdateWindow(unsigned int handle);
void OsLinux_Set_FileTime(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime);
bool OsLinux_HL_Crypt(unsigned short* data);
bool OsLinux_HL_Login(unsigned short address, const unsigned char* label, const unsigned char* password);
bool OsLinux_HL_Logout() ;

View File

@ -20,6 +20,12 @@
#include <psapi.h>
#include <shlobj.h>
template<typename T> void safe_delete(T*& a)
{
delete a;
a = nullptr;
}
bool OsWin32_CheckPrinterInfo(const void* data, unsigned int size)
{
bool ok = data != NULL;
@ -912,6 +918,50 @@ wxIcon OsWin32_LoadIcon(const char* filename)
return ico;
}
static void TimetToFileTime(time_t t, LPFILETIME pft)
{
ULARGE_INTEGER time_value;
time_value.QuadPart = (t * 10000000LL) + 116444736000000000LL;
pft->dwLowDateTime = time_value.LowPart;
pft->dwHighDateTime = time_value.HighPart;
}
void OsWin32_Set_FileTime(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime)
{
HANDLE h = CreateFileA(file, FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
FILETIME *fctime = nullptr;
FILETIME *fatime = nullptr;
FILETIME *fmtime = nullptr;
if (ctime != nullptr)
{
time_t t = mktime(ctime);
fctime = new FILETIME;
TimetToFileTime(t, fctime);
}
if (atime != nullptr)
{
time_t t = mktime(atime);
fatime = new FILETIME;
TimetToFileTime(t, fatime);
}
if (mtime != nullptr)
{
time_t t = mktime(mtime);
fmtime = new FILETIME;
TimetToFileTime(t, fmtime);
}
SetFileTime(h, fctime, fatime, fmtime);
safe_delete(fctime);
safe_delete(fatime);
safe_delete(fmtime);
CloseHandle(h);
}
// action = [ open, edit, print ];
bool OsWin32_GotoUrl(const char* url, const char* action)
{

View File

@ -10,6 +10,8 @@ wxString OsWin32_File2App(const char* filename);
bool OsWin32_GotoUrl(const char* url, const char* action);
wxIcon OsWin32_LoadIcon(const char* file);
void OsWin32_Set_FileTime(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime);
int OsWin32_EnumerateFamilies(WXHDC hDC, char** families, int max_count);
int OsWin32_EnumerateSizes(WXHDC hDC, const char* name, long* sizes, short* scalable, int max_count);
void OsWin32_SetCaptionStyle(WXHWND handle, long style);

View File

@ -1840,8 +1840,17 @@ long xvt_fsys_file_attr(const char* path, long attr)
// Original XVT implementation
long xvt_fsys_get_file_attr(const FILE_SPEC* fs, long attr)
{
char mbs[_MAX_PATH]; xvt_fsys_convert_fspec_to_str(fs, mbs, sizeof(mbs));
return xvt_fsys_file_attr(mbs, attr);
char mbs[_MAX_PATH]; xvt_fsys_convert_fspec_to_str(fs, mbs, sizeof(mbs));
return xvt_fsys_file_attr(mbs, attr);
}
void xvt_fsys_set_file_time(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime)
{
#ifdef __WXMSW__
OsWin32_Set_FileTime(file, ctime, atime, mtime);
#else
Oslinux_Set_FileTime(file, ctime, atime, mtime);
#endif
}
///////////////////////////////////////////////////////////
@ -3542,7 +3551,7 @@ long xvt_sys_execute(const char* cmdline, BOOLEAN sync, BOOLEAN iconizetask)
delete p;
}
else
exitcode = wxExecute(cmd, wxEXEC_ASYNC /* | wxEXEC_HIDE_CONSOLE*/);
exitcode = wxExecute(cmd, wxEXEC_ASYNC);
}
return exitcode;

View File

@ -188,6 +188,7 @@ XVTDLL void xvt_fsys_restore_dir();
XVTDLL void xvt_fsys_save_dir();
XVTDLL BOOLEAN xvt_fsys_set_dir(const DIRECTORY* dirp);
XVTDLL long xvt_fsys_get_file_attr(const FILE_SPEC *fs, long attr);
XVTDLL void xvt_fsys_set_file_time(const char * file, struct tm * ctime, struct tm * atime, struct tm * mtime);
XVTDLL BOOLEAN xvt_fsys_fcopy(const char* orig, const char* dest);
// Added by Guy