Aggiunta funzione dexist per testare esistenza cartelle

Corretta gestione tabelle di modulo contenenti il codice cliente


git-svn-id: svn://10.65.10.50/branches/R_10_00@22848 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2013-05-06 08:50:32 +00:00
parent e4e44ab7f4
commit 2c144f4dac
10 changed files with 1492 additions and 1508 deletions

View File

@ -29,7 +29,7 @@ int TArchive::build_backup_list(int mode, long firm, TString_array& fl) const
for (int err = ditte.first(); err == NOERR; err = ditte.next())
{
const char* dir = firm2dir(ditte.get_long(NDT_CODDITTA));
if (fexist(dir))
if (dexist(dir))
fl.add(dir);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -372,7 +372,7 @@ bool TGolem_field::autosave(TRelation& r)
TFilename golem_path;
golem_path = firm2dir(ditta);
golem_path.add("golem");
if (!fexist(golem_path))
if (!dexist(golem_path))
make_dir(golem_path);
const int old_items = _old_value.items();

View File

@ -1747,7 +1747,7 @@ int TSystemisamfile::build(const TTrec& r)
TFilename fname(f); fname.ext(""); // sostituto per _filename
f = f.path(); if (!is_not_slash(f.right(1)[0])) f.rtrim(1);
if (!fexist(f))
if (!dexist(f))
make_dir(f);
err=DB_build(fname, &r.rec());

View File

@ -651,22 +651,18 @@ TMask_field& TMask::field(short id) const
int TMask::field2pos(const char* fieldname) const
{
const int id = atoi(fieldname);
if (real::is_natural(fieldname))
{
const short id = atoi(fieldname);
return id2pos(id);
}
int i;
for (i = fields()-1; i >= 0; i--)
{
TMask_field& f = fld(i);
if (id == 0)
{
const TFieldref* fr = f.field();
if (fr != NULL && fr->name() == fieldname)
break;
}
else
{
if (f.dlg() == id)
break;
}
const TFieldref* fr = f.field();
if (fr != NULL && fr->name() == fieldname)
break;
}
return i;
}

View File

@ -59,8 +59,7 @@ bool TTable_module_application::user_create()
if (argc() < 3)
return false;
TString4 tabname;
tabname.strncpy(argv(2), 4);
TString16 tabname = argv(2);
tabname.upper();
if (tabname[0] != '&')
tabname.insert("&"); // Forza la tabella di modulo

View File

@ -946,7 +946,7 @@ TPrefix::TPrefix() : _filelevel(0), _stdlevel(0), _items(0), _firm(NULL)
_prefix = ".";
const char* prfx = CGetPref();
if (!fexist(__ptprf) || strchr(__ptprf, ' ') != NULL)
if (!dexist(__ptprf) || strchr(__ptprf, ' ') != NULL)
fatal_box(FR("Percorso dati non valido: '%s'"), __ptprf);
const TFilename dir(prfx);

View File

@ -365,21 +365,6 @@ int TString::rfind(
return p ? int(p - _str) : -1;
}
#if XVT_OS == XVT_OS_SCOUNIX
HIDDEN const char* strstr(const char* string1, const char* string2)
{
const int len = strlen(string2);
while (*string1)
{
if (strncmp(string1, string2, len) == 0)
return string1;
string1++;
}
return NULL;
}
#endif
// Certified 100%
int TString::find(const char* s, int from) const
{
@ -1281,7 +1266,6 @@ const TFilename& TFilename::tempdir()
xvt_sys_get_env("TEMP", _tempdir.get_buffer(), _tempdir.size());
if (_tempdir.empty())
xvt_sys_get_env("TMP", _tempdir.get_buffer(), _tempdir.size());
#ifdef WIN32
if (_tempdir.empty())
{
_tempdir = __argv[0];
@ -1294,9 +1278,6 @@ const TFilename& TFilename::tempdir()
_tempdir.cut(3);
_tempdir << "tmp";
}
#else
_tempdir = "/tmp";
#endif
const int last = len()-1;
if (!is_not_slash(_str[last]))
@ -1305,7 +1286,7 @@ const TFilename& TFilename::tempdir()
bool ok = true;
_tempdir.lower();
if (!_tempdir.exist())
if (!dexist(_tempdir))
ok = make_dir(_tempdir);
if (ok)
@ -1318,12 +1299,13 @@ const TFilename& TFilename::tempdir()
if (f < 0 || f != _tempdir.len() - theuser.len())
_tempdir << SLASH << theuser;
_tempdir.lower();
if (!_tempdir.exist())
if (!dexist(_tempdir))
ok = make_dir(_tempdir);
}
if (!ok)
fatal_box("Impossibile creare la directory '%s' per i file temporanei", (const char*)_tempdir);
fatal_box("Impossibile creare la directory '%s' per i file temporanei",
(const char*)_tempdir);
xvt_sys_set_env("TMP", _tempdir);
}
@ -1418,7 +1400,7 @@ const TFilename& TFilename::temp(
free(t);
}
CHECKS(!exist(), "Il file temporaneo esiste gia': ", _str);
CHECKS(!exist(), "Il file temporaneo esiste già: ", _str);
return *this;
}
@ -1464,7 +1446,7 @@ bool TFilename::search_in_path(TFilename& path) const
xvt_sys_search_env(_str, "PATH", path.get_buffer());
if (path.empty())
xvt_sys_search_env(_str, "path", path.get_buffer());
return path.not_empty();
return path.full();
}
bool TFilename::input()

View File

@ -150,9 +150,15 @@ bool fcopy(
bool fexist(
const char* file) // @parm Nome del file di cui contrallare l'esistenza
{
return xvt_fsys_access(file, 0x00) == 0;
return xvt_fsys_file_exists(file) != 0;
}
bool dexist(
const char* file) // @parm Nome del file di cui contrallare l'esistenza
{
return xvt_fsys_dir_exists(file) != 0;
}
long fsize(const char* name)
{
return xvt_fsys_file_attr(name, XVT_FILE_ATTR_SIZE);

View File

@ -32,6 +32,7 @@ const char* itor(int i);
bool fcopy(const char* orig, const char* dest, bool append = false, bool advanced = false);
bool fexist(const char* file);
long fsize(const char* file);
bool dexist(const char* file);
void log_message(const char* fmt, ...);
bool make_dir(const char* dir);