mask.cpp Migliorata scelta sheet cui mandare Alt+
strings.cpp Migliorata generazione nomi di file temporanei tabutil.cpp Aggiuornato uso della list_files utility.cpp Migliorata la list_files aggiungendo un parametro utility.h Cambiato prototipo della list_files git-svn-id: svn://10.65.10.50/trunk@5342 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
7c5f62cb56
commit
2b38285053
@ -767,7 +767,7 @@ bool TMask::on_key(
|
||||
case K_CTRL+'+':
|
||||
if (is_running())
|
||||
{
|
||||
for (int fire = _focus-1; fire <= _focus+1; fire++)
|
||||
for (int fire = _focus+1; fire >= _focus-1; fire--)
|
||||
{
|
||||
if (fire >= 0 && fire < fields())
|
||||
{
|
||||
|
@ -1144,20 +1144,36 @@ const TFilename& TFilename::temp(
|
||||
{
|
||||
if (extension && *extension)
|
||||
{
|
||||
static unsigned long numero = 0;
|
||||
TFilename mask(prefix);
|
||||
if (mask.empty())
|
||||
mask.tempdir();
|
||||
|
||||
TFilename prefisso(prefix);
|
||||
if (prefisso.empty())
|
||||
prefisso.tempdir();
|
||||
if (is_not_slash(prefisso.right(1)[0]))
|
||||
prefisso << SLASH;
|
||||
|
||||
// Childish: You could use findfirst!
|
||||
do
|
||||
{
|
||||
format("%s%ld", prefisso.get_buffer(), ++numero);
|
||||
ext(extension);
|
||||
} while (fexist(_str));
|
||||
mask.add("*");
|
||||
mask.ext(extension);
|
||||
const int preflen = strlen(mask.path());
|
||||
|
||||
TString_array list;
|
||||
const int count = list_files(mask, list);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
const char* name = (const char*)list.row(i) + preflen;
|
||||
const long numero = atol(name) + 1;
|
||||
mask.cut(preflen);
|
||||
mask << numero;
|
||||
mask.ext(extension);
|
||||
if (list.find(mask) < 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const int star = mask.find('*');
|
||||
mask[star] = '1';
|
||||
}
|
||||
set(mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1192,7 +1208,7 @@ const TFilename& TFilename::temp(
|
||||
|
||||
#ifdef DBG
|
||||
if (fexist(_str))
|
||||
fatal_box("Il file '%s' esiste gia'", _str);
|
||||
yesnofatal_box("Il file temporaneo '%s' esiste gia'", _str);
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
|
@ -207,11 +207,11 @@ void TTable::load_module_description()
|
||||
n << _tabname;
|
||||
n.ext("msk");
|
||||
n.lower();
|
||||
TToken_string f;
|
||||
f.add(n);
|
||||
if (list_files(f) == 1)
|
||||
|
||||
TString_array f;
|
||||
if (list_files(n, f) == 1)
|
||||
{
|
||||
n = f.get(0);
|
||||
n = f.row(0);
|
||||
if (!fexist(n))
|
||||
n.overwrite("ba",0);
|
||||
if (fexist(n))
|
||||
|
@ -10,6 +10,9 @@
|
||||
#include <xvt.h>
|
||||
#endif
|
||||
|
||||
#include <xvtility.h>
|
||||
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN || XVT_OS == XVT_OS_WIN32
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
@ -146,40 +149,44 @@ bool make_dir(
|
||||
// @rdesc Ritorna il numero di file che soddisfano la condizione passata (numero di elementi
|
||||
// della token string)
|
||||
int list_files(
|
||||
TToken_string& filelist) // @parm Stringa contenente la condizione di estrazione
|
||||
// della lista dei file
|
||||
const char* filelist, // @parm Stringa contenente la maschera di estrazione
|
||||
TString_array& result) // @parm Array da riempire con la lista dei file
|
||||
|
||||
// @comm Per comodita' la lista desiderata vine anch'essa messa in <p filelist> in quanto e'
|
||||
// gia' costruita
|
||||
{
|
||||
TFilename dir(filelist.get(0));
|
||||
{
|
||||
TWait_cursor hourglass;
|
||||
TFilename dir(filelist);
|
||||
for (int i = dir.len()-1; i >= 0; i--)
|
||||
if (dir[i] == '/' || dir[i] == '\\') break;
|
||||
|
||||
const TString16 mask(dir.mid(i+1));
|
||||
TFilename mask(dir.mid(i+1));
|
||||
dir.cut(i > 0 ? i : 0);
|
||||
|
||||
xvt_fsys_save_dir();
|
||||
DIRECTORY directory; xvt_fsys_convert_str_to_dir((char*)(const char*)dir, &directory);
|
||||
BOOLEAN ok = xvt_fsys_set_dir(&directory);
|
||||
if (!ok) fatal_box ("Impossibile entrare in %s", (const char*)dir);
|
||||
|
||||
SLIST files = xvt_fsys_list_files("", (char*)(const char*)mask, FALSE);
|
||||
xvt_fsys_save_dir();
|
||||
|
||||
if (dir.not_empty())
|
||||
{
|
||||
DIRECTORY directory; xvt_fsys_convert_str_to_dir(dir.get_buffer(), &directory);
|
||||
BOOLEAN ok = xvt_fsys_set_dir(&directory);
|
||||
if (!ok)
|
||||
fatal_box ("Impossibile entrare in %s", (const char*)dir);
|
||||
}
|
||||
|
||||
SLIST files = xvt_fsys_list_files("", mask.get_buffer(), FALSE);
|
||||
const int count = xvt_slist_count(files);
|
||||
filelist.spaces(count*12);
|
||||
filelist.cut(0);
|
||||
|
||||
for (SLIST_ELT e = xvt_slist_get_first(files); e; e = xvt_slist_get_next(files, e))
|
||||
{
|
||||
char* f = xvt_slist_get(files, e, NULL);
|
||||
if (dir.not_empty())
|
||||
{
|
||||
filelist.add(dir);
|
||||
filelist << '/' << f;
|
||||
mask = dir;
|
||||
mask.add(f);
|
||||
result.add(mask);
|
||||
}
|
||||
else
|
||||
filelist.add(f);
|
||||
result.add(f);
|
||||
}
|
||||
|
||||
xvt_slist_destroy(files);
|
||||
|
@ -16,7 +16,7 @@ enum os_type { os_Windows, os_Win32s, os_Windows95, os_WindowsNT };
|
||||
os_type get_os_type();
|
||||
|
||||
bool make_dir(const char* file);
|
||||
int list_files(TToken_string& names);
|
||||
int list_files(const char* mask, TString_array& result);
|
||||
const char * encode(const char* data);
|
||||
const char * decode(const char* data);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user