forked from aniani/vim
patch 8.2.0320: no Haiku support
Problem: No Haiku support. Solution: Add support for Haiku. (Emir Sari, closes #5605)
This commit is contained in:
214
src/fileio.c
214
src/fileio.c
@@ -3367,6 +3367,7 @@ shorten_fnames(int force)
|
||||
#if (defined(FEAT_DND) && defined(FEAT_GUI_GTK)) \
|
||||
|| defined(FEAT_GUI_MSWIN) \
|
||||
|| defined(FEAT_GUI_MAC) \
|
||||
|| defined(FEAT_GUI_HAIKU) \
|
||||
|| defined(PROTO)
|
||||
/*
|
||||
* Shorten all filenames in "fnames[count]" by current directory.
|
||||
@@ -4422,130 +4423,133 @@ readdir_core(
|
||||
void *context,
|
||||
int (*checkitem)(void *context, char_u *name))
|
||||
{
|
||||
int failed = FALSE;
|
||||
# ifdef MSWIN
|
||||
char_u *buf, *p;
|
||||
int ok;
|
||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATAW wfb;
|
||||
WCHAR *wn = NULL; // UTF-16 name, NULL when not used.
|
||||
# endif
|
||||
int failed = FALSE;
|
||||
char_u *p;
|
||||
|
||||
ga_init2(gap, (int)sizeof(char *), 20);
|
||||
|
||||
# ifdef MSWIN
|
||||
buf = alloc(MAXPATHL);
|
||||
if (buf == NULL)
|
||||
return FAIL;
|
||||
STRNCPY(buf, path, MAXPATHL-5);
|
||||
p = buf + STRLEN(buf);
|
||||
MB_PTR_BACK(buf, p);
|
||||
if (*p == '\\' || *p == '/')
|
||||
*p = NUL;
|
||||
STRCAT(buf, "\\*");
|
||||
{
|
||||
char_u *buf;
|
||||
int ok;
|
||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATAW wfb;
|
||||
WCHAR *wn = NULL; // UTF-16 name, NULL when not used.
|
||||
|
||||
wn = enc_to_utf16(buf, NULL);
|
||||
if (wn != NULL)
|
||||
hFind = FindFirstFileW(wn, &wfb);
|
||||
ok = (hFind != INVALID_HANDLE_VALUE);
|
||||
if (!ok)
|
||||
{
|
||||
failed = TRUE;
|
||||
smsg(_(e_notopen), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (ok)
|
||||
buf = alloc(MAXPATHL);
|
||||
if (buf == NULL)
|
||||
return FAIL;
|
||||
STRNCPY(buf, path, MAXPATHL-5);
|
||||
p = buf + STRLEN(buf);
|
||||
MB_PTR_BACK(buf, p);
|
||||
if (*p == '\\' || *p == '/')
|
||||
*p = NUL;
|
||||
STRCAT(buf, "\\*");
|
||||
|
||||
wn = enc_to_utf16(buf, NULL);
|
||||
if (wn != NULL)
|
||||
hFind = FindFirstFileW(wn, &wfb);
|
||||
ok = (hFind != INVALID_HANDLE_VALUE);
|
||||
if (!ok)
|
||||
{
|
||||
int ignore;
|
||||
|
||||
p = utf16_to_enc(wfb.cFileName, NULL); // p is allocated here
|
||||
if (p == NULL)
|
||||
break; // out of memory
|
||||
|
||||
ignore = p[0] == '.' && (p[1] == NUL
|
||||
|| (p[1] == '.' && p[2] == NUL));
|
||||
if (!ignore && checkitem != NULL)
|
||||
{
|
||||
int r = checkitem(context, p);
|
||||
|
||||
if (r < 0)
|
||||
{
|
||||
vim_free(p);
|
||||
break;
|
||||
}
|
||||
if (r == 0)
|
||||
ignore = TRUE;
|
||||
}
|
||||
|
||||
if (!ignore)
|
||||
{
|
||||
if (ga_grow(gap, 1) == OK)
|
||||
((char_u**)gap->ga_data)[gap->ga_len++] = vim_strsave(p);
|
||||
else
|
||||
{
|
||||
failed = TRUE;
|
||||
vim_free(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vim_free(p);
|
||||
ok = FindNextFileW(hFind, &wfb);
|
||||
failed = TRUE;
|
||||
smsg(_(e_notopen), path);
|
||||
}
|
||||
FindClose(hFind);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (ok)
|
||||
{
|
||||
int ignore;
|
||||
|
||||
vim_free(buf);
|
||||
vim_free(wn);
|
||||
p = utf16_to_enc(wfb.cFileName, NULL); // p is allocated here
|
||||
if (p == NULL)
|
||||
break; // out of memory
|
||||
|
||||
ignore = p[0] == '.' && (p[1] == NUL
|
||||
|| (p[1] == '.' && p[2] == NUL));
|
||||
if (!ignore && checkitem != NULL)
|
||||
{
|
||||
int r = checkitem(context, p);
|
||||
|
||||
if (r < 0)
|
||||
{
|
||||
vim_free(p);
|
||||
break;
|
||||
}
|
||||
if (r == 0)
|
||||
ignore = TRUE;
|
||||
}
|
||||
|
||||
if (!ignore)
|
||||
{
|
||||
if (ga_grow(gap, 1) == OK)
|
||||
((char_u**)gap->ga_data)[gap->ga_len++] = vim_strsave(p);
|
||||
else
|
||||
{
|
||||
failed = TRUE;
|
||||
vim_free(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vim_free(p);
|
||||
ok = FindNextFileW(hFind, &wfb);
|
||||
}
|
||||
FindClose(hFind);
|
||||
}
|
||||
|
||||
vim_free(buf);
|
||||
vim_free(wn);
|
||||
}
|
||||
# else
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char_u *p;
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
|
||||
dirp = opendir((char *)path);
|
||||
if (dirp == NULL)
|
||||
{
|
||||
failed = TRUE;
|
||||
smsg(_(e_notopen), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (;;)
|
||||
dirp = opendir((char *)path);
|
||||
if (dirp == NULL)
|
||||
{
|
||||
int ignore;
|
||||
|
||||
dp = readdir(dirp);
|
||||
if (dp == NULL)
|
||||
break;
|
||||
p = (char_u *)dp->d_name;
|
||||
|
||||
ignore = p[0] == '.' &&
|
||||
(p[1] == NUL ||
|
||||
(p[1] == '.' && p[2] == NUL));
|
||||
if (!ignore && checkitem != NULL)
|
||||
failed = TRUE;
|
||||
smsg(_(e_notopen), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int r = checkitem(context, p);
|
||||
int ignore;
|
||||
|
||||
if (r < 0)
|
||||
dp = readdir(dirp);
|
||||
if (dp == NULL)
|
||||
break;
|
||||
if (r == 0)
|
||||
ignore = TRUE;
|
||||
}
|
||||
p = (char_u *)dp->d_name;
|
||||
|
||||
if (!ignore)
|
||||
{
|
||||
if (ga_grow(gap, 1) == OK)
|
||||
((char_u**)gap->ga_data)[gap->ga_len++] = vim_strsave(p);
|
||||
else
|
||||
ignore = p[0] == '.' &&
|
||||
(p[1] == NUL ||
|
||||
(p[1] == '.' && p[2] == NUL));
|
||||
if (!ignore && checkitem != NULL)
|
||||
{
|
||||
failed = TRUE;
|
||||
break;
|
||||
int r = checkitem(context, p);
|
||||
|
||||
if (r < 0)
|
||||
break;
|
||||
if (r == 0)
|
||||
ignore = TRUE;
|
||||
}
|
||||
|
||||
if (!ignore)
|
||||
{
|
||||
if (ga_grow(gap, 1) == OK)
|
||||
((char_u**)gap->ga_data)[gap->ga_len++] = vim_strsave(p);
|
||||
else
|
||||
{
|
||||
failed = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
closedir(dirp);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
|
Reference in New Issue
Block a user