Copy filename escaping code from e_utils to make it more generally available.

Step 2 is to remove the original and have everything call this one instead.


SVN revision: 26828
This commit is contained in:
David Walter Seikel 2006-10-28 08:48:11 +00:00
parent c7722b50d8
commit be5de6cdb3
2 changed files with 35 additions and 0 deletions

View File

@ -76,6 +76,7 @@ extern "C" {
EAPI char *ecore_file_readlink (const char *link);
EAPI Ecore_List *ecore_file_ls (const char *dir);
EAPI char *ecore_file_app_exe_get (const char *app);
EAPI char *ecore_file_escape_name (const char *filename);
EAPI char *ecore_file_strip_ext (const char *file);
EAPI Ecore_File_Monitor *ecore_file_monitor_add(const char *path,

View File

@ -479,6 +479,40 @@ restart:
return exe;
}
EAPI char *
ecore_file_escape_name(const char *filename)
{
const char *p;
char *q;
static char buf[PATH_MAX];
p = filename;
q = buf;
while (*p)
{
if ((q - buf) > (PATH_MAX - 6)) return NULL;
if (
(*p == ' ') || (*p == '\t') || (*p == '\n') ||
(*p == '\\') || (*p == '\'') || (*p == '\"') ||
(*p == ';') || (*p == '!') || (*p == '#') ||
(*p == '$') || (*p == '%') || (*p == '&') ||
(*p == '*') || (*p == '(') || (*p == ')') ||
(*p == '[') || (*p == ']') || (*p == '{') ||
(*p == '}') || (*p == '|') || (*p == '<') ||
(*p == '>') || (*p == '?')
)
{
*q = '\\';
q++;
}
*q = *p;
q++;
p++;
}
*q = 0;
return strdup(buf);
}
EAPI char *
ecore_file_strip_ext(const char *path)
{