ba0.cpp Usato metodo remove_all dei TConfig per settare corretamente dirty
ba1600* Mitico fascicolator ba1700* Mistico sfascicolator git-svn-id: svn://10.65.10.50/trunk@5598 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
801039dd79
commit
7ee82412b9
@ -1449,13 +1449,14 @@ bool TMenu_application::choose_editors()
|
||||
|
||||
if (m.run() == K_ENTER)
|
||||
{
|
||||
var.destroy();
|
||||
link.remove_all();
|
||||
for (int r = sheet.items()-1; r >= 0; r--)
|
||||
{
|
||||
TToken_string& row = sheet.row(r);
|
||||
TString16 ext = row.get(0);
|
||||
if (!ext.blank())
|
||||
{
|
||||
{
|
||||
ext.lower();
|
||||
TFilename prg = row.get();
|
||||
link.set(ext, prg);
|
||||
}
|
||||
|
143
ba/ba1600.cpp
143
ba/ba1600.cpp
@ -3,6 +3,7 @@
|
||||
#include <applicat.h>
|
||||
#include <execp.h>
|
||||
#include <msksheet.h>
|
||||
#include <prefix.h>
|
||||
#include <progind.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
@ -71,12 +72,12 @@ int TInstall_ini::build_complete_list(const TString& module, TString_array& a,
|
||||
FOR_EACH_TOKEN(altri, mod)
|
||||
{
|
||||
const TString submodule = mod;
|
||||
copy_paragraph(submodule, sommario);
|
||||
export_paragraph(submodule, sommario);
|
||||
}
|
||||
return a.items();
|
||||
}
|
||||
|
||||
void TInstall_ini::copy_paragraph(const char* module, const char* summary)
|
||||
void TInstall_ini::export_paragraph(const char* module, const char* summary)
|
||||
{
|
||||
TConfig sum(summary, module);
|
||||
TAssoc_array& ass = (TAssoc_array&)list_variables(module);
|
||||
@ -84,7 +85,7 @@ void TInstall_ini::copy_paragraph(const char* module, const char* summary)
|
||||
sum.set(key, str);
|
||||
}
|
||||
|
||||
void TInstall_ini::copy_module_paragraphs(const char* module, const char* summary)
|
||||
void TInstall_ini::export_module_paragraphs(const char* module, const char* summary)
|
||||
{
|
||||
TString mod;
|
||||
for (int sub = -1; ; sub++)
|
||||
@ -92,12 +93,64 @@ void TInstall_ini::copy_module_paragraphs(const char* module, const char* summar
|
||||
mod = module;
|
||||
if (sub >= 0) mod << sub;
|
||||
if (set_paragraph(mod))
|
||||
copy_paragraph(module, summary);
|
||||
export_paragraph(mod, summary);
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TFconv_ini
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TFconv_ini : public TConfig
|
||||
{
|
||||
public:
|
||||
void export_module(const char* module, const char* summary);
|
||||
|
||||
TFconv_ini(const char* path = "fconv.ini") : TConfig(path) { }
|
||||
virtual ~TFconv_ini() { }
|
||||
};
|
||||
|
||||
void TFconv_ini::export_module(const char* module, const char* summary)
|
||||
{
|
||||
TScanner scanner("prassi.aut");
|
||||
int module_code;
|
||||
for (module_code = 0; scanner.line().not_empty(); module_code++)
|
||||
{
|
||||
if (scanner.token().compare(module, 2, TRUE) == 0)
|
||||
break;
|
||||
}
|
||||
scanner.close();
|
||||
|
||||
TConfig sommario(summary);
|
||||
|
||||
TString_array paragraphs;
|
||||
list_paragraphs(paragraphs);
|
||||
paragraphs.sort();
|
||||
|
||||
FOR_EACH_ARRAY_ROW(paragraphs, p, para)
|
||||
{
|
||||
set_paragraph(*para);
|
||||
TAssoc_array& variables = (TAssoc_array&)list_variables();
|
||||
FOR_EACH_ASSOC_STRING(variables, obj, key, str)
|
||||
{
|
||||
const char* parenthesis = strchr(key, '(');
|
||||
if (parenthesis)
|
||||
{
|
||||
const int logic_num = atoi(parenthesis+1);
|
||||
if (logic_num > 0)
|
||||
{
|
||||
TDir dirinfo; dirinfo.get(logic_num);
|
||||
const long flags = dirinfo.flags() % 10000;
|
||||
if (flags == module_code)
|
||||
sommario.set(key, str, module);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TAuto_token_string
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -485,11 +538,14 @@ class TFascicolator_mask : public TMask
|
||||
protected:
|
||||
static bool list_handler(TMask_field& f, KEY k);
|
||||
static bool save_handler(TMask_field& f, KEY k);
|
||||
static bool import_export_handler(TMask_field& f, KEY k);
|
||||
|
||||
bool zip_file(const char* archive, const char* file) const;
|
||||
int split_file(const TFilename& file, long size) const;
|
||||
bool move_file(const TFilename& file, const char* dir) const;
|
||||
bool zip_module(const TString& module, bool agg) const;
|
||||
|
||||
const TFilename& build_export_path(TFilename& path) const;
|
||||
|
||||
public:
|
||||
void load();
|
||||
@ -535,6 +591,77 @@ bool TFascicolator_mask::save_handler(TMask_field& f, KEY k)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TFascicolator_mask::import_export_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
const bool is_export = f.dlg() == S_EXPORT;
|
||||
const TMask& m = f.mask();
|
||||
const TString& module = m.get(S_MODULE);
|
||||
|
||||
const TFascicolator_mask& fm = (const TFascicolator_mask&)m.get_sheet()->mask();
|
||||
TFilename path;
|
||||
fm.build_export_path(path);
|
||||
|
||||
FILE_SPEC fs;
|
||||
xvt_fsys_convert_str_to_dir(path.get_buffer(), &fs.dir);
|
||||
path.add(module); path << "inst.ini"; path.lower();
|
||||
strcpy(fs.type, "ini");
|
||||
strcpy(fs.name, path.name());
|
||||
strcpy(fs.creator, "INST");
|
||||
|
||||
bool ok;
|
||||
|
||||
DIRECTORY dir;
|
||||
xvt_fsys_get_dir(&dir); // Salva directory corrente (Non usare la bacata xvt_fsys_save_dir)
|
||||
if (is_export)
|
||||
ok = xvt_dm_post_file_save(&fs, "Esporta il modulo in:") == FL_OK;
|
||||
else
|
||||
ok = xvt_dm_post_file_open(&fs, "Importa il modulo da:") == FL_OK;
|
||||
xvt_fsys_set_dir(&dir); // Ripristina directory corrente
|
||||
|
||||
if (ok)
|
||||
{
|
||||
if (is_export)
|
||||
{
|
||||
TInstall_ini inst;
|
||||
inst.export_module_paragraphs(module, path);
|
||||
|
||||
TFconv_ini fconv;
|
||||
path = path.path();
|
||||
path.add(module); path << "fconv.ini";
|
||||
fconv.export_module(module, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
TInstall_ini ini(path);
|
||||
ini.export_module_paragraphs(module, ini.default_name());
|
||||
|
||||
path = path.path();
|
||||
path.add(module); path << "fconv.ini";
|
||||
TFconv_ini fconv(path);
|
||||
fconv.export_module(module, "fconv.ini");
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const TFilename& TFascicolator_mask::build_export_path(TFilename& path) const
|
||||
{
|
||||
const TString& module = get(S_MODULE);
|
||||
path.cut(0);
|
||||
path << SLASH << 'u' << SLASH << user() << SLASH << "src" << SLASH << module;
|
||||
if (!fexist(path))
|
||||
{
|
||||
path.cut(0);
|
||||
path << SLASH << 'u' << SLASH << user() << SLASH << "p.due" << SLASH << module;
|
||||
}
|
||||
if (!fexist(path))
|
||||
path.tempdir();
|
||||
return path;
|
||||
}
|
||||
|
||||
void TFascicolator_mask::load()
|
||||
{
|
||||
TWait_cursor hourglass;
|
||||
@ -622,7 +749,7 @@ void TFascicolator_mask::save()
|
||||
bool TFascicolator_mask::zip_file(const char* archive, const char* file) const
|
||||
{
|
||||
TWait_cursor hourglass;
|
||||
TFilename cmd(120);
|
||||
TFilename cmd;
|
||||
cmd << "zip.pif " << archive << ' ' << file;
|
||||
TExternal_app app(cmd);
|
||||
int err = app.run(FALSE, FALSE, FALSE, FALSE);
|
||||
@ -761,7 +888,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
|
||||
msg << "Creazione del file " << archivio << " ...";
|
||||
|
||||
TProgind pi(arr.items(), msg, TRUE, TRUE);
|
||||
TFilename cmd;
|
||||
TString cmd(120);
|
||||
|
||||
FOR_EACH_ARRAY_ROW_BACK(arr, i, row)
|
||||
{
|
||||
@ -793,7 +920,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg) const
|
||||
|
||||
// Memorizza il numero dei dischetti nel sommario
|
||||
ini.set("Dischi", disks, main_module); // Aggiorna install.ini
|
||||
ini.copy_paragraph(main_module, sommario); // Aggiorna sommario
|
||||
ini.export_paragraph(main_module, sommario); // Aggiorna sommario
|
||||
|
||||
// Se non specifico un path ho gia' finito
|
||||
const TFilename path = get(F_DISKPATH);
|
||||
@ -839,6 +966,8 @@ TFascicolator_mask::TFascicolator_mask()
|
||||
m.set_handler(S_LIST, list_handler);
|
||||
m.set_handler(S_SAVE, save_handler);
|
||||
m.set_handler(S_SAVEAGG, save_handler);
|
||||
m.set_handler(S_IMPORT, import_export_handler);
|
||||
m.set_handler(S_EXPORT, import_export_handler);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
|
30
ba/ba1600.h
30
ba/ba1600.h
@ -13,8 +13,8 @@ public:
|
||||
int build_complete_list(const TString& m, TString_array& a,
|
||||
const char* s = NULL, bool agg = FALSE);
|
||||
|
||||
void copy_paragraph(const char* module, const char* summary);
|
||||
void copy_module_paragraphs(const char* module, const char* summary);
|
||||
void export_paragraph(const char* module, const char* summary);
|
||||
void export_module_paragraphs(const char* module, const char* summary);
|
||||
|
||||
static const char* default_name() { return "install.ini"; }
|
||||
|
||||
@ -39,31 +39,31 @@ public:
|
||||
virtual ~TAuto_token_string() { }
|
||||
};
|
||||
|
||||
#define FOR_EACH_SHEET_ROW(__sheet, __r, __riga) \
|
||||
TToken_string* __riga; \
|
||||
for (int __r = 0; \
|
||||
__r < __sheet.items() && (const char*)(__riga = &__sheet.row(__r)); \
|
||||
__r++)
|
||||
|
||||
#define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) \
|
||||
TToken_string* __riga; \
|
||||
for (int __r = __sheet.items()-1; \
|
||||
__r >= 0 && (const char*)(__riga = &__sheet.row(__r)); \
|
||||
__r--)
|
||||
#define FOR_EACH_ARRAY_ROW(__arr, __r, __riga) \
|
||||
TToken_string* __riga; \
|
||||
for (int __r = __arr.first(); \
|
||||
__riga = (TToken_string*)__arr.objptr(__r); \
|
||||
__r = __arr.succ(__r))
|
||||
|
||||
#define FOR_EACH_ARRAY_ROW_BACK(__arr, __r, __riga) \
|
||||
TToken_string* __riga; \
|
||||
for (int __r = __arr.last(); \
|
||||
__r >= 0 && (const char*)(__riga = &__arr.row(__r)); \
|
||||
__riga = (TToken_string*)__arr.objptr(__r); \
|
||||
__r = __arr.pred(__r))
|
||||
|
||||
#define FOR_EACH_SHEET_ROW(__sheet, __r, __riga) \
|
||||
FOR_EACH_ARRAY_ROW(__sheet.rows_array(), __r, __riga)
|
||||
|
||||
#define FOR_EACH_SHEET_ROW_BACK(__sheet, __r, __riga) \
|
||||
FOR_EACH_ARRAY_ROW_BACK(__sheet.rows_array(), __r, __riga)
|
||||
|
||||
#define FOR_EACH_ASSOC_STRING(__ass, __obj, __key, __str) \
|
||||
const char *__key, *__str; __ass.restart; \
|
||||
for (THash_object* __obj = __ass.get_hashobj(); \
|
||||
__obj && (__str = (const TString&)__obj->obj(), __key = __obj->key()); \
|
||||
__obj = __ass.get_hashobj())
|
||||
|
||||
#define FOR_EACH_TOKEN(__tok, __str) \
|
||||
#define FOR_EACH_TOKEN(__tok, __str) \
|
||||
for (const char* __str = __tok.get(0); __str; __str = __tok.get())
|
||||
|
||||
#endif
|
||||
|
@ -19,5 +19,7 @@
|
||||
#define S_LIST 100
|
||||
#define S_SAVE 151
|
||||
#define S_SAVEAGG 152
|
||||
#define S_IMPORT 153
|
||||
#define S_EXPORT 154
|
||||
|
||||
#endif
|
||||
|
@ -86,7 +86,7 @@ BEGIN
|
||||
PROMPT 1 5 "Post-processing "
|
||||
END
|
||||
|
||||
BUTTON DLG_OK 14 2
|
||||
BUTTON DLG_CANCEL 14 2
|
||||
BEGIN
|
||||
PROMPT -13 -3 ""
|
||||
END
|
||||
@ -108,12 +108,12 @@ END
|
||||
|
||||
BUTTON S_IMPORT 14 2
|
||||
BEGIN
|
||||
PROMPT -33 -3 "&Versione"
|
||||
PROMPT -33 -3 "&Importa"
|
||||
END
|
||||
|
||||
BUTTON S_EXPORT 14 2
|
||||
BEGIN
|
||||
PROMPT -33 -1 "&Aggiornamento"
|
||||
PROMPT -33 -1 "&Esporta"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
@ -284,7 +284,7 @@ bool TInstaller_mask::install(const TString& module)
|
||||
if (ok)
|
||||
{
|
||||
post_process(ini, module);
|
||||
ini.copy_module_paragraphs(module, ini.default_name());
|
||||
ini.export_module_paragraphs(module, ini.default_name());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -317,7 +317,7 @@ bool TInstaller_mask::install(const TString& module)
|
||||
|
||||
if (ok)
|
||||
{
|
||||
ini.copy_module_paragraphs(module, ini.default_name());
|
||||
ini.export_module_paragraphs(module, ini.default_name());
|
||||
post_process(ini, module);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user