diff --git a/ba/ba0.cpp b/ba/ba0.cpp index 9afc16eb9..90adbf83d 100755 --- a/ba/ba0.cpp +++ b/ba/ba0.cpp @@ -1,18 +1,14 @@ -#define STRICT -#define XVT_INCL_NATIVE - #include #include #include #include #include -#include #include +#include #include #include #include -#include #include #include @@ -553,7 +549,7 @@ bool TMenuitem::enabled() const for (int e = 0; ext[e]; e++) { name.ext(ext[e]); - if (fexist(name)) + if (name.exist()) break; } yes = ext[e] != NULL; @@ -988,7 +984,6 @@ protected: // TApplication virtual bool create(); virtual bool destroy(); virtual bool menu(MENU_TAG m); - virtual bool build_firm_data(long cod, bool flagcom = FALSE); virtual long handler(WINDOW win, EVENT* ep); protected: @@ -1018,120 +1013,6 @@ inline TMenu_application& app() { return (TMenu_application&)main_app(); } -bool TMenu_application::build_firm_data(long codditta, bool flagcom) -{ - const char * const ndir = "/dir.gen"; - const char * const ntrc = "/trc.gen"; - TFilename s(firm2dir(codditta)); s << ndir; - bool exist = fexist(s); - - if (!exist) - { - s = s.path(); s.rtrim(1); s << ntrc; - exist = fexist(s); - } - if (exist) - return message_box("Direttorio dati danneggiato, impossibile attivare la ditta %ld", codditta); - if (!yesno_box("Gli archivi della ditta %ld non esistono: si desidera generarli?", codditta)) - return FALSE; - - TLocalisamfile ditte(LF_NDITTE); - ditte.zero(); - ditte.put(NDT_CODDITTA,codditta); - if (ditte.read(_isequal,_testandlock) == _islocked) - { - message_box("Archivi della ditta %ld in fase di creazione da parte di un altro utente.",codditta); - return FALSE; - } - - set_autoload_new_files(yesno_box("Si desidera precaricare gli archivi standard")); - s = s.path(); s.rtrim(1); - - if (!fexist(s) && !make_dir(s)) - return error_box("Impossibile creare il direttorio della ditta %ld (%s)", - codditta, (const char*)s); - - s << ndir; - if (!fcopy(&ndir[1], s)) - return error_box("Impossibile copiare il file %s della ditta %ld", - &ndir[1], codditta); - s = s.path(); s << ntrc; - if (!fcopy(&ntrc[1], s)) - return error_box("Impossibile copiare il file %s della ditta %ld", - ntrc, codditta); - - TDir dir, dir1; - TTrec rec; - - prefix().set(""); - dir1.get(LF_DIR, _nolock, _nordir, _sysdirop); - const long maxeod0 = dir1.eod(); - - prefix().set_codditta(codditta); - dir.get(LF_DIR, _nolock, _nordir, _sysdirop); - if (dir.eod() == 0) - { - dir1.eod() = 1L; - dir1.put(LF_DIR, _nordir, _sysdirop); - dir.get(LF_DIR, _nolock, _nordir, _sysdirop); - } - const long maxeod1 = dir.eod(); - - if (maxeod0 > maxeod1) - { - dir.get(LF_DIR, _nolock, _nordir, _sysdirop); - dir.eod() = maxeod0; - dir.put(LF_DIR, _nordir, _sysdirop); - rec.zero(); - } - TString mess("Generazione archivi della ditta "); mess << codditta; - TProgind p(maxeod0 ? maxeod0 : 1, mess, FALSE, TRUE, 70); - - for (int i = LF_DIR + 1; i <= maxeod0; i++) - { - p.addstatus(1); - prefix().set(""); - dir.get(i, _nolock, _nordir, _sysdirop); - rec.get(i); - bool create_now = dir.is_active(); - - prefix().set_codditta(codditta); - dir.put(i, _nordir, _sysdirop); - rec.put(i); - const char* name = dir.name(); - dir.flags() = 0L; - create_now = create_now && (flagcom ? dir.is_com() : dir.is_firm()); - - if (dir.is_valid() && create_now) - { - TSystemisamfile f(i); - f.build(30); - } - else - { - dir.put(i, _nordir, _sysdirop); - rec.put(i); - } - } - - TConfig c(CONFIG_STUDIO, "cg"); - - if (c.get_bool("StiReg")) - { - TTable reg("REG"); - for (reg.first(_lock); reg.good(); reg.next(_lock)) - { - reg.put("B9", "X"); - reg.rewrite(); - } - } - ditte.reread(_unlock); - - set_firm(codditta); - set_autoload_new_files(TRUE); - - return TRUE; -} bool TMenu_application::menu_item_handler(TMask_field&f, KEY k) { @@ -1390,13 +1271,11 @@ bool TMenu_application::check_user() } } -#if XVT_OS == XVT_OS_WIN if (ok && utente != "PRASSI") { TConfig prawin(CONFIG_INSTALL, "Main"); prawin.set("User", utente); } -#endif return ok; } diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index ccc604e37..2ff57ba41 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -1,39 +1,21 @@ -#include -#include #include #include -// Serve per GetFreeSpace -#define XVT_INCL_NATIVE -#define STRICT - #include +#include +#include #include #include +#include #include #include #include #include #include -#include -#include -#include #include "ba1.h" #include "ba1100.h" -#if XVT_OS==XVT_OS_SCOUNIX -#define DIRSIZ 14 -struct direct -{ - unsigned short d_ino; - char d_name[DIRSIZ]; -}; -#else -#include -#include -#endif - #define History_file "conv.his" #define Dir_file "dir.gen" #define Trc_file "trc.gen" @@ -105,49 +87,6 @@ HIDDEN bool browse_file_handler(TMask_field& f, KEY k) return TRUE; } -HIDDEN void build_filelist(const char *path, TArray & list) -{ -#if XVT_OS==XVT_OS_SCOUNIX - struct directx - { - ino_t d_ino; - char d_name[DIRSIZ + 1]; - } dlink; - int fd; - - if ((fd = open(path, 0)) == -1) - return; - dlink.d_name[DIRSIZ] = '\0'; - while(read(fd, &dlink, sizeof(struct direct)) == - sizeof(struct direct)) - { - if (dlink.d_ino > 0) - { - TFixed_string dname(dlink.d_name); - - if (dname.find(".des") > 0 && dname[0] == 'd' && !isdigit(dname[1])) - list.add(dname.mid(1,3)); - } - } - close(fd); -#else - _find_t f; - - if (_dos_findfirst("recdesc/d???.des", _A_NORMAL, &f) == 0) - { - bool one_to_add = TRUE; - while (one_to_add) - { - TString80 dname(f.name); - - if (!isdigit(dname[1])) - list.add(dname.mid(1,3)); - one_to_add = _dos_findnext(&f) == 0; - } - } -#endif -} - TManutenzione_app::TManutenzione_app() : _browse(NULL), _rec(NULL), _mask(NULL), _firm(0), _level(0) { if (!fexist(Dir_file)) // controlla l'esistenza dei direttori standard (dir.gen e trc.gen) @@ -334,16 +273,17 @@ void TManutenzione_app::print() } delete pi; - TArray list; - build_filelist(DESCDIR, list); - items = list.items(); + TString_array list; + items = list_files("recdesc/d???.des", list); pi = new TProgind(items,"Stampa descrizione tabelle", TRUE, TRUE, 63); - + + TString16 tab; for (i = 0; !pi->iscancelled() && i < items; i++) { - TString & tab = (TString &) list[i]; + tab = list.row(i).right(7); + tab.cut(3); TRec_sheet r(4, tab); pi->addstatus(1); @@ -556,12 +496,7 @@ void TManutenzione_app::dump_trc(const char * dir, const bool des_too, const lon const char* TManutenzione_app::dumpfilename(const FileDes& dep) const { TFilename n; n.tempdir(); -#if XVT_OS == XVT_OS_SCOUNIX - n << '/'; -#else - n << '\\'; -#endif - n << dep.SysName; + n.add(dep.SysName); n.strip("$%"); n.ext("txt"); n.lower(); @@ -700,7 +635,7 @@ void TManutenzione_app::edit_riga (long riga_sel, TToken_string& riga) f.packfile(); f.packindex(); //Pack supplementare tramite FOXPRO (da togliere con CodeBase 6) -#if XVT_OS == XVT_OS_WIN +#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32 if (logicnum > 2 && logicnum < 6 && f.status() == NOERR) if (fexist("packaga.exe")) { @@ -814,9 +749,7 @@ void TManutenzione_app::update_dir() prompt = "Aggiornamento direttorio "; if (is_com) prompt << "comune"; else prompt << " della ditta " << atol(pref) <<"."; -#if XVT_OS == XVT_OS_WIN - prompt << " Memoria libera: " << (long)GetFreeSpace(0)/1024 << " Kbytes."; -#endif + prompt << " Memoria libera: " << long(os_get_free_memory()/1024) << " Kbytes."; TProgind p(update_items ? update_items : 1, prompt, FALSE, TRUE, 70); p.setstatus(1); @@ -1075,9 +1008,7 @@ void TManutenzione_app::convert_dir() if (is_com) s << "comuni."; else s << "della ditta " << atol (pref) << "."; -#if XVT_OS == XVT_OS_WIN - s << " Memoria libera: " << (long)GetFreeSpace(0)/1024 << " Kbytes."; -#endif + s << " Memoria libera: " << long(os_get_free_memory()/1024) << " Kbytes."; TProgind p(update_items ? update_items : 1, s, FALSE, TRUE, 70); p.setstatus(1); @@ -1201,11 +1132,8 @@ void TManutenzione_app::load_des() TFilename fn; TDir td,new_dir; TTrec tr; -#if XVT_OS == XVT_OS_WIN - struct _find_t c_file; -#endif + int ln = items,last_newln = items; - bool firstime = TRUE,ok; tr.zero(); fn << DESCDIR << "/level.dir"; @@ -1219,45 +1147,39 @@ void TManutenzione_app::load_des() //unlink(fn); } - // scandisce *.dir in RECDESC tramite dos_findfirst e _dos_findnext + // scandisce *.dir in RECDESC // eventuali "buchi" oltre al numero attuale di items vengono rimpiazzati // con tracciati vuoti. fn.format("%s/f*.dir",DESCDIR); -#if XVT_OS == XVT_OS_WIN - do + + TString_array list; + const int totfiles = list_files(fn, list); + + for (int n = 0; n < totfiles; n++) { - if (firstime) + fn = list.row(n); + infile.open(fn); + infile >> td; + ln = td.num(); + const bool is_new = ln > last_newln; // memorizza l'ultimo record scritto come nuovo + if (is_new) // aggiunge i files che mancano { - ok = _dos_findfirst(fn, _A_NORMAL, &c_file ) == 0; - firstime = FALSE; - } - fn.format("%s/%s",DESCDIR,c_file.name); - if (ok) - { - infile.open(fn); - infile >> td; - ln = td.num(); - const bool is_new = ln > last_newln; // memorizza l'ultimo record scritto come nuovo - if (is_new) // aggiunge i files che mancano + for (int i = last_newln+1; i items) // rialloca openf altrimenti la TPrefix::closeall() provoca un grazioso errore in applicazione { @@ -1401,9 +1323,8 @@ void TManutenzione_app::update() const TRecnotype rec = ditte.recno(); const long codditta = ditte.get_long("CODDITTA"); mxs = s; -#if XVT_OS == XVT_OS_WIN - mxs << " Ditta " << codditta << ". Memoria libera: " << (long)GetFreeSpace(0)/1024 << " Kbytes."; -#endif + mxs << " Ditta " << codditta << ". Memoria libera: " + << long(os_get_free_memory()/1024) << " Kbytes."; p.addstatus(1); p.set_text(mxs); if (codditta > _history_firm && prefix().exist(codditta)) diff --git a/ba/ba1500.cpp b/ba/ba1500.cpp index b36c9beb9..1b47cabfb 100755 --- a/ba/ba1500.cpp +++ b/ba/ba1500.cpp @@ -797,7 +797,7 @@ bool TAttivazione_moduli::aggiorna_listino_handler(TMask_field& fld, KEY key) TInstall_ini ini; TFilename name = ini.get("DiskPath"); name.add(ini.default_name()); - while (!fexist(name)) + while (!name.exist()) { TMask msk("Aggiornamento listino", 1, -1, -1, 60, 4); msk.add_string(DLG_USER, 0, "Percorso", 1, 1, 50); diff --git a/ba/ba1600.cpp b/ba/ba1600.cpp index 682e318ba..18ca4d783 100755 --- a/ba/ba1600.cpp +++ b/ba/ba1600.cpp @@ -1,16 +1,13 @@ -#include - -#define XVT_INCL_NATIVE #include +#include #include #include #include +#include #include #include -#include -#include - #include +#include #include "ba1.h" #include "ba1600.h" @@ -991,22 +988,12 @@ bool TFascicolator_mask::move_file(const TFilename& file, const char* dir) const bool space_ok = FALSE; while (!space_ok) { - int disk = 0; - if (dest[1] == ':') - { - const char letter = toupper(dest[0]); - disk = 'A' - letter + 1; - } - struct _diskfree_t drive; - _dos_getdiskfree(disk, &drive); - - const unsigned requested_clusters = unsigned(filesize / drive.sectors_per_cluster / drive.bytes_per_sector) + 1; - space_ok = requested_clusters <= drive.avail_clusters; + space_ok = ::os_test_disk_free_space(dest, filesize); if (!space_ok) { TString msg(128); msg << "Lo spazio sull'unita' e' insufficiente"; - if (GetDriveType(disk-1) == DRIVE_REMOVABLE) + if (::os_is_removable_drive(dest)) { msg << ":\nInserire un nuovo disco e ritentare?"; if (!yesno_box(msg)) @@ -1267,13 +1254,12 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg, int pa ini.set("Dischi", disks, main_module); // Aggiorna install.ini ini.export_paragraph(main_module, sommario); // Aggiorna sommario - const char drive = toupper(path[0]); - const bool floppy = (GetDriveType(drive - 'A') == DRIVE_REMOVABLE) && (path[1] == ':'); + const bool floppy = ::os_is_removable_drive(path); for (int d = 1; d <= disks && !aborted; d++) { if (floppy) - message_box("Inserire il disco %d di %d nell'unita' %c:", d, disks, drive); + message_box("Inserire il disco %d di %d nell'unita':", d, disks); // Costruisco il nome del file da copiare su dischetto TFilename src(archivio); diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 5947c001b..84caa5b7c 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -1,9 +1,7 @@ -#include - -#define XVT_INCL_NATIVE #include #include -#include +#include +#include #include #include #include @@ -13,6 +11,7 @@ #include "ba1500.h" #include "ba1600.h" #include "ba1700a.h" + // definizioni delle colonne dello sheet #define C_MODULE 1 #define C_CODE 2 @@ -24,14 +23,6 @@ #define C_CURRDATAREL 8 #define C_ISPATCH 9 -HIDDEN int noyes_box(const char* msg) -{ - MessageBeep(MB_ICONQUESTION); - int r = MessageBox(GetFocus(), msg, "RICHIESTA", - MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2); - return r == IDYES; -} - HIDDEN int compare_version(const char* v1, int p1, const char* v2, int p2) { TString16 ver1(v1), ver2(v2); @@ -419,16 +410,13 @@ bool TInstaller_mask::move_file(const TFilename& from, const TFilename& file, co const char letter = toupper(dest[0]); disk = 'A' - letter + 1; } - struct _diskfree_t drive; - _dos_getdiskfree(disk, &drive); - - const unsigned requested_clusters = unsigned(filesize / drive.sectors_per_cluster / drive.bytes_per_sector) + 1; - space_ok = requested_clusters <= drive.avail_clusters; + + space_ok = ::os_test_disk_free_space(dest, filesize); if (!space_ok) { TString msg; msg << "Lo spazio sull'unita' e' insufficiente"; - if (GetDriveType(disk-1) == DRIVE_REMOVABLE) + if (::os_is_removable_drive(dest)) { msg << ":\nInserire un nuovo disco e ritentare?"; if (!yesno_box(msg)) @@ -558,11 +546,8 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) if (ok) { - struct _diskfree_t drive; - _dos_getdiskfree(0, &drive); const long required = fsize(cmdline) * (dischi-d+1) * 4; - const unsigned requested_clusters = unsigned(required / drive.sectors_per_cluster / drive.bytes_per_sector) + 1; - if (requested_clusters >= drive.avail_clusters) + if (::os_test_disk_free_space("", required)) { ok = yesno_box("Lo spazio su disco potrebbe essere insufficiente:\n" "Si desidera continuare ugualmente?"); @@ -859,8 +844,7 @@ TInstaller_mask::TInstaller_mask() set(F_PATH, path); const char lettera = toupper(path[0]); - const bool floppy = (path.len() > 1) && path[1] == ':' && - GetDriveType(lettera - 'A') == DRIVE_REMOVABLE; + const bool floppy = ::os_is_removable_drive(path); if (path.not_empty() && !floppy) autoload(); diff --git a/ba/ba2.cpp b/ba/ba2.cpp index 1381441ed..551e157c7 100755 --- a/ba/ba2.cpp +++ b/ba/ba2.cpp @@ -17,10 +17,6 @@ int main(int argc, char** argv) rt = ba2100(argc, argv); break; case 1: rt = ba2200(argc, argv); break; -#if XVT_OS == XVT_OS_SCOUNIX - case 2: - rt = ba2300(argc, argv) ; break; -#endif case 3: rt = ba2400(argc, argv) ; break; case 4: diff --git a/ba/ba2200.cpp b/ba/ba2200.cpp index 30400e67e..1520b2470 100755 --- a/ba/ba2200.cpp +++ b/ba/ba2200.cpp @@ -1,33 +1,22 @@ -#include - -#define XVT_INCL_NATIVE -#define STRICT - #include -#include -#include +#include #include #include #include -#include -#include -#include -#include #include "ba2200.h" - /////////////////////////////////////////////////////////// // Archiving application /////////////////////////////////////////////////////////// -class TArchive_app : public TApplication +class TArchive_app : public TSkeleton_application { TArchive _arc; protected: virtual bool create(); - virtual bool menu(MENU_TAG); + virtual void main_loop(); static bool test_firm(TMask_field& f, KEY k); KEY query(long& firm, char& floppy, TString& desc, bool& tmp) const; @@ -40,8 +29,6 @@ public: bool TArchive_app::create() { - TApplication::create(); - bool ok = TRUE; TIsamfile utenti(LF_USER, FALSE); @@ -58,7 +45,7 @@ bool TArchive_app::create() utenti.close(); if (ok) - dispatch_e_menu(BAR_ITEM(1)); + ok = TSkeleton_application::create(); return ok; } @@ -97,12 +84,12 @@ KEY TArchive_app::query(long& firm, char& floppy, TString& desc, bool& temp) con return k; } -bool TArchive_app::menu(MENU_TAG) +void TArchive_app::main_loop() { KEY k; long firm; char floppy; - TString80 desc; + TString desc(80); bool temp; while ((k = query(firm, floppy, desc, temp)) != K_QUIT) @@ -110,8 +97,6 @@ bool TArchive_app::menu(MENU_TAG) if (k == K_SAVE) _arc.backup(firm, floppy, desc); else _arc.restore(firm, floppy, temp); } - - return FALSE; } int ba2200(int argc, char* argv[]) diff --git a/ba/ba6101.cpp b/ba/ba6101.cpp index 0315fb959..c7461c59b 100755 --- a/ba/ba6101.cpp +++ b/ba/ba6101.cpp @@ -4,9 +4,6 @@ // ************************************************************************ #include "ba6100.h" -static const char sep[] = -"-----------------------------------------------------------------" -"-----------------------------------------------------------------" ; void TAnaprint_app::set_scheda_anagiu() { @@ -945,24 +942,14 @@ void TAnaprint_app::set_headers() { case anafis: case anagiu: -#if XVT_OS != XVT_OS_SCOUNIX set_background("W1l{1 2 132 2}W4l{1 4 132 4}"); -#else - set_header(2,(const char*)sep); - set_header(4,(const char*)sep); -#endif set_header(1,"@bRUBRICA PERSONE %s@40gStudio@53gData @< pag. @#", _pr_what == anagiu ? "GIURIDICHE" : "FISICHE"); set_header(3,"@iCodice Cognome e nome"); set_header(5,""); break; case nditte: -#if XVT_OS != XVT_OS_SCOUNIX set_background("W1l{1 2 132 2}W4l{1 4 132 4}"); -#else - set_header(2,(const char*)sep); - set_header(4,(const char*)sep); -#endif set_header(1,"@bRUBRICA DITTE@40gStudio@53gData @< pag. @#"); set_header(3,"@iCodice Cognome e nome"); set_header(5,""); diff --git a/ba/ba6200.cpp b/ba/ba6200.cpp index 875f681f5..d44f6b7e6 100755 --- a/ba/ba6200.cpp +++ b/ba/ba6200.cpp @@ -1,20 +1,11 @@ #include #include -#include -#include -#include -#include -#include #include #include "ba6.h" #include "ba6200.h" -const MAXSTR = 128; -static char __tmp [MAXSTR]; -static TFixed_string tmp (__tmp, MAXSTR); - class BA6200_application : public TPrintapp { TRelation* _rel; @@ -269,11 +260,8 @@ bool BA6200_application::user_destroy() int ba6200(int argc, char* argv[]) { - BA6200_application a; - a.run(argc, argv, "Stampa Comuni"); - return 0; }