2016-04-29 03:55:42 +00:00
|
|
|
#include <qse/si/glob.h>
|
|
|
|
#include <qse/si/sio.h>
|
2012-08-30 16:36:37 +00:00
|
|
|
#include <qse/cmn/main.h>
|
|
|
|
#include <qse/cmn/mbwc.h>
|
|
|
|
#include <qse/cmn/str.h>
|
|
|
|
#include <qse/cmn/mem.h>
|
2014-12-15 04:26:41 +00:00
|
|
|
#include <qse/cmn/fmt.h>
|
2012-08-31 13:00:33 +00:00
|
|
|
#include <qse/cmn/path.h>
|
|
|
|
|
2012-08-30 16:36:37 +00:00
|
|
|
#include <locale.h>
|
|
|
|
#if defined(_WIN32)
|
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2012-08-31 13:00:33 +00:00
|
|
|
static int print (const qse_cstr_t* path, void* ctx)
|
|
|
|
{
|
2012-09-01 16:05:40 +00:00
|
|
|
qse_printf (QSE_T("[%.*s]\n"), (int)path->len, path->ptr);
|
2012-08-31 13:00:33 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-30 16:36:37 +00:00
|
|
|
static int glob_main (int argc, qse_char_t* argv[])
|
|
|
|
{
|
2012-08-31 13:00:33 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (argc <= 1)
|
|
|
|
{
|
2012-09-01 16:05:40 +00:00
|
|
|
qse_fprintf (QSE_STDERR, QSE_T("Usage: %s file-pattern ...\n"), qse_basename(argv[0]));
|
2012-08-31 13:00:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < argc; i++)
|
|
|
|
{
|
2014-12-15 04:26:41 +00:00
|
|
|
if (qse_glob (argv[i], print, QSE_NULL, QSE_GLOB_PERIOD,
|
|
|
|
qse_getdflmmgr(), qse_getdflcmgr()) <= -1) return -1;
|
2012-08-31 13:00:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2012-08-30 16:36:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int qse_main (int argc, qse_achar_t* argv[])
|
|
|
|
{
|
2014-12-15 04:26:41 +00:00
|
|
|
int x;
|
2012-08-30 16:36:37 +00:00
|
|
|
#if defined(_WIN32)
|
2012-10-15 09:46:29 +00:00
|
|
|
char locale[100];
|
2014-12-15 04:26:41 +00:00
|
|
|
UINT codepage = GetConsoleOutputCP();
|
2012-08-30 16:36:37 +00:00
|
|
|
if (codepage == CP_UTF8)
|
|
|
|
{
|
|
|
|
/*SetConsoleOUtputCP (CP_UTF8);*/
|
2012-10-15 09:36:39 +00:00
|
|
|
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
|
2012-08-30 16:36:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-12-15 04:26:41 +00:00
|
|
|
/* .codepage */
|
|
|
|
qse_fmtuintmaxtombs (locale, QSE_COUNTOF(locale),
|
|
|
|
codepage, 10, -1, QSE_MT('\0'), QSE_MT("."));
|
|
|
|
setlocale (LC_ALL, locale);
|
2015-04-27 08:37:57 +00:00
|
|
|
/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
|
2012-08-30 16:36:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2014-12-15 04:26:41 +00:00
|
|
|
setlocale (LC_ALL, "");
|
2015-04-27 08:37:57 +00:00
|
|
|
/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
|
2012-08-30 16:36:37 +00:00
|
|
|
#endif
|
2014-12-15 04:26:41 +00:00
|
|
|
|
2017-09-16 08:54:25 +00:00
|
|
|
qse_open_stdsios ();
|
2014-12-15 04:26:41 +00:00
|
|
|
|
2018-09-13 03:16:23 +00:00
|
|
|
x = qse_run_main (argc, argv, glob_main);
|
2014-12-15 04:26:41 +00:00
|
|
|
|
2017-09-16 08:54:25 +00:00
|
|
|
qse_close_stdsios ();
|
2014-12-15 04:26:41 +00:00
|
|
|
|
|
|
|
return x;
|
2012-08-30 16:36:37 +00:00
|
|
|
}
|
|
|
|
|