Aggiunta funzionme per testare esistenza cartelle (non solo file)
git-svn-id: svn://10.65.10.50/branches/R_10_00@22862 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
cb52f86f76
commit
11da9586be
@ -1501,8 +1501,8 @@ TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create, bool
|
||||
if (!create)
|
||||
{
|
||||
const long sz = fsize(n);
|
||||
if (sz == 0)
|
||||
fatal_box("Impossibile aprire il file %s: %s",(const char*)n, (const char*)_strerror(NULL));
|
||||
if (sz <= 64)
|
||||
fatal_box("Impossibile aprire il file %s", (const char*)n);
|
||||
|
||||
const TDir dir(logicnum);
|
||||
const long len = dir.len();
|
||||
@ -1561,11 +1561,28 @@ int TIsamtempfile::open(
|
||||
fatal_box("Can't create temp file '%s' num. %d: Error n. %d", (const char*)filename, num(), err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TFilename test = filename; test.ext("dbf");
|
||||
for (int t = 0; t < 2; t++)
|
||||
{
|
||||
test.ext(t == 0 ? "dbf" : "cdx");
|
||||
if (!test.exist())
|
||||
{
|
||||
err = -60;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (err == NOERR)
|
||||
{
|
||||
_isam_handle = prefix().open_isamfile(_logicnum, filename);
|
||||
TCodeb_handle fhnd = handle(_curr_key = 1);
|
||||
if (fhnd < 0)
|
||||
err = get_error(fhnd);
|
||||
}
|
||||
|
||||
_isam_handle = prefix().open_isamfile(_logicnum, filename);
|
||||
TCodeb_handle fhnd = handle(_curr_key = 1);
|
||||
if (fhnd < 0)
|
||||
err = get_error(fhnd);
|
||||
if (err != NOERR)
|
||||
{
|
||||
filename.ext("dbf");
|
||||
|
@ -1092,10 +1092,10 @@ bool TPrefix::test(const char* s) const
|
||||
if (s1.exist())
|
||||
{
|
||||
if (xvt_fsys_access(s1, 0x2) != 0)
|
||||
return error_box(FR("Impossibile accedere in lettura/scrittura al file '%s'"), (const char*)s1);
|
||||
return cantwrite_box(s1);
|
||||
}
|
||||
else
|
||||
return error_box(FR("Impossibile trovare il file '%s'"), (const char*)s1);
|
||||
return cantread_box(s1);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1156,7 +1156,7 @@ const char* TPrefix::get_studio() const
|
||||
bool TPrefix::set_studio(const char* study, long ditta)
|
||||
{
|
||||
TFilename dirtest(study);
|
||||
if (!dirtest.exist() || dirtest.find(' ') >= 0)
|
||||
if (!dexist(dirtest) || dirtest.find(' ') >= 0)
|
||||
return false;
|
||||
|
||||
dirtest.add("com/dir.gen");
|
||||
@ -1293,7 +1293,7 @@ bool TPrefix::build_firm_data(long codditta, bool flagcom)
|
||||
exist = s.exist();
|
||||
}
|
||||
if (exist)
|
||||
return message_box("Direttorio dati danneggiato, impossibile attivare la ditta %ld", codditta);
|
||||
return message_box("Cartella dati danneggiata, impossibile attivare la ditta %ld", codditta);
|
||||
if (!yesno_box("Gli archivi della ditta %ld non esistono: si desidera generarli?", codditta))
|
||||
return false;
|
||||
|
||||
@ -1301,7 +1301,7 @@ bool TPrefix::build_firm_data(long codditta, bool flagcom)
|
||||
s = s.path(); s.rtrim(1);
|
||||
|
||||
if (!s.exist() && !make_dir(s))
|
||||
return error_box("Impossibile creare il direttorio della ditta %ld (%s)",
|
||||
return error_box("Impossibile creare la cartella della ditta %ld (%s)",
|
||||
codditta, (const char*)s);
|
||||
|
||||
s.add(ndir);
|
||||
|
@ -217,7 +217,7 @@ int TRecord_array::rec2row(const TRectype& r) const
|
||||
else
|
||||
n = r.get_int(_num); // Non e' detto che sia un int!
|
||||
n -= _offset;
|
||||
CHECKD(n >= 0 && n < 30000, "Bad line number in record ", n + _offset);
|
||||
CHECKD(n >= 0 && n <= 99999, "Bad line number in record ", n + _offset);
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -150,18 +150,18 @@ bool fcopy(
|
||||
bool fexist(
|
||||
const char* file) // @parm Nome del file di cui contrallare l'esistenza
|
||||
{
|
||||
return xvt_fsys_file_exists(file) != 0;
|
||||
return file && *file && 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;
|
||||
return file && *file && xvt_fsys_dir_exists(file) != 0;
|
||||
}
|
||||
|
||||
long fsize(const char* name)
|
||||
{
|
||||
return xvt_fsys_file_attr(name, XVT_FILE_ATTR_SIZE);
|
||||
return (name && *name) ? xvt_fsys_file_attr(name, XVT_FILE_ATTR_SIZE) : 0L;
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
|
Loading…
x
Reference in New Issue
Block a user