Commit d9a27e9c authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

kernel32: Implement CheckNameLegalDOS8Dot3.

parent 5f35f1a8
......@@ -218,8 +218,8 @@
# @ stub CheckElevation
# @ stub CheckElevationEnabled
# @ stub CheckForReadOnlyResource
# @ stub CheckNameLegalDOS8Dot3A
# @ stub CheckNameLegalDOS8Dot3W
@ stdcall CheckNameLegalDOS8Dot3A(str ptr long ptr ptr)
@ stdcall CheckNameLegalDOS8Dot3W(wstr ptr long ptr ptr)
@ stdcall CheckRemoteDebuggerPresent(long ptr)
@ stdcall ClearCommBreak(long)
@ stdcall ClearCommError(long ptr ptr)
......
......@@ -2012,3 +2012,52 @@ BOOL WINAPI CreateHardLinkTransactedW(LPCWSTR link, LPCWSTR target, LPSECURITY_A
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/*************************************************************************
* CheckNameLegalDOS8Dot3A (KERNEL32.@)
*/
BOOL WINAPI CheckNameLegalDOS8Dot3A(const char *name, char *oemname, DWORD oemname_len,
BOOL *contains_spaces, BOOL *is_legal)
{
WCHAR *nameW;
TRACE("(%s %p %u %p %p)\n", name, oemname,
oemname_len, contains_spaces, is_legal);
if (!name || !is_legal)
return FALSE;
if (!(nameW = FILE_name_AtoW( name, FALSE ))) return FALSE;
return CheckNameLegalDOS8Dot3W( nameW, oemname, oemname_len, contains_spaces, is_legal );
}
/*************************************************************************
* CheckNameLegalDOS8Dot3W (KERNEL32.@)
*/
BOOL WINAPI CheckNameLegalDOS8Dot3W(const WCHAR *name, char *oemname, DWORD oemname_len,
BOOL *contains_spaces_ret, BOOL *is_legal)
{
OEM_STRING oem_str;
UNICODE_STRING nameW;
BOOLEAN contains_spaces;
TRACE("(%s %p %u %p %p)\n", wine_dbgstr_w(name), oemname,
oemname_len, contains_spaces_ret, is_legal);
if (!name || !is_legal)
return FALSE;
RtlInitUnicodeString( &nameW, name );
if (oemname) {
oem_str.Length = oemname_len;
oem_str.MaximumLength = oemname_len;
oem_str.Buffer = oemname;
}
*is_legal = RtlIsNameLegalDOS8Dot3( &nameW, oemname ? &oem_str : NULL, &contains_spaces );
if (contains_spaces_ret) *contains_spaces_ret = contains_spaces;
return TRUE;
}
......@@ -75,6 +75,9 @@ static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
static BOOL (WINAPI *pGetCurrentActCtx)(HANDLE *);
static void (WINAPI *pReleaseActCtx)(HANDLE);
static BOOL (WINAPI *pCheckNameLegalDOS8Dot3W)(const WCHAR *, char *, DWORD, BOOL *, BOOL *);
static BOOL (WINAPI *pCheckNameLegalDOS8Dot3A)(const char *, char *, DWORD, BOOL *, BOOL *);
/* a structure to deal with wine todos somewhat cleanly */
typedef struct {
DWORD shortlen;
......@@ -2058,6 +2061,8 @@ static void init_pointers(void)
MAKEFUNC(DeactivateActCtx);
MAKEFUNC(GetCurrentActCtx);
MAKEFUNC(ReleaseActCtx);
MAKEFUNC(CheckNameLegalDOS8Dot3W);
MAKEFUNC(CheckNameLegalDOS8Dot3A);
#undef MAKEFUNC
}
......@@ -2119,6 +2124,73 @@ static void test_relative_path(void)
RemoveDirectoryA("bar");
}
static void test_CheckNameLegalDOS8Dot3(void)
{
static const WCHAR has_driveW[] = {'C',':','\\','a','.','t','x','t',0};
static const WCHAR has_pathW[] = {'b','\\','a','.','t','x','t',0};
static const WCHAR too_longW[] = {'a','l','o','n','g','f','i','l','e','n','a','m','e','.','t','x','t',0};
static const WCHAR twodotsW[] = {'t','e','s','t','.','e','s','t','.','t','x','t',0};
static const WCHAR longextW[] = {'t','e','s','t','.','t','x','t','t','x','t',0};
static const WCHAR emptyW[] = {0};
static const WCHAR funnycharsW[] = {'!','#','$','%','&','\'','(',')','.','-','@','^',0};
static const WCHAR length8W[] = {'t','e','s','t','t','e','s','t','.','t','x','t',0};
static const WCHAR length1W[] = {'t',0};
static const WCHAR withspaceW[] = {'t','e','s','t',' ','e','s','t','.','t','x','t',0};
static const struct {
const WCHAR *name;
BOOL should_be_legal, has_space;
} cases[] = {
{has_driveW, FALSE, FALSE},
{has_pathW, FALSE, FALSE},
{too_longW, FALSE, FALSE},
{twodotsW, FALSE, FALSE},
{longextW, FALSE, FALSE},
{emptyW, TRUE /* ! */, FALSE},
{funnycharsW, TRUE, FALSE},
{length8W, TRUE, FALSE},
{length1W, TRUE, FALSE},
{withspaceW, TRUE, TRUE},
};
BOOL br, is_legal, has_space;
char astr[64];
DWORD i;
if(!pCheckNameLegalDOS8Dot3W){
win_skip("Missing CheckNameLegalDOS8Dot3, skipping tests\n");
return;
}
br = pCheckNameLegalDOS8Dot3W(NULL, NULL, 0, NULL, &is_legal);
ok(br == FALSE, "CheckNameLegalDOS8Dot3W should have failed\n");
br = pCheckNameLegalDOS8Dot3A(NULL, NULL, 0, NULL, &is_legal);
ok(br == FALSE, "CheckNameLegalDOS8Dot3A should have failed\n");
br = pCheckNameLegalDOS8Dot3W(length8W, NULL, 0, NULL, NULL);
ok(br == FALSE, "CheckNameLegalDOS8Dot3W should have failed\n");
br = pCheckNameLegalDOS8Dot3A("testtest.txt", NULL, 0, NULL, NULL);
ok(br == FALSE, "CheckNameLegalDOS8Dot3A should have failed\n");
for(i = 0; i < sizeof(cases)/sizeof(*cases); ++i){
br = pCheckNameLegalDOS8Dot3W(cases[i].name, NULL, 0, &has_space, &is_legal);
ok(br == TRUE, "CheckNameLegalDOS8Dot3W failed for %s\n", wine_dbgstr_w(cases[i].name));
ok(is_legal == cases[i].should_be_legal, "Got wrong legality for %s\n", wine_dbgstr_w(cases[i].name));
if(is_legal)
ok(has_space == cases[i].has_space, "Got wrong space for %s\n", wine_dbgstr_w(cases[i].name));
WideCharToMultiByte(CP_ACP, 0, cases[i].name, -1, astr, sizeof(astr), NULL, NULL);
br = pCheckNameLegalDOS8Dot3A(astr, NULL, 0, &has_space, &is_legal);
ok(br == TRUE, "CheckNameLegalDOS8Dot3W failed for %s\n", astr);
ok(is_legal == cases[i].should_be_legal, "Got wrong legality for %s\n", astr);
if(is_legal)
ok(has_space == cases[i].has_space, "Got wrong space for %s\n", wine_dbgstr_w(cases[i].name));
}
}
START_TEST(path)
{
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
......@@ -2151,4 +2223,5 @@ START_TEST(path)
test_SearchPathW();
test_GetFullPathNameA();
test_GetFullPathNameW();
test_CheckNameLegalDOS8Dot3();
}
......@@ -1614,6 +1614,8 @@ WINBASEAPI BOOL WINAPI CancelIo(HANDLE);
WINBASEAPI BOOL WINAPI CancelIoEx(HANDLE,LPOVERLAPPED);
WINBASEAPI BOOL WINAPI CancelTimerQueueTimer(HANDLE,HANDLE);
WINBASEAPI BOOL WINAPI CancelWaitableTimer(HANDLE);
WINBASEAPI BOOL WINAPI CheckNameLegalDOS8Dot3A(const char*,char*,DWORD,BOOL*,BOOL*);
WINBASEAPI BOOL WINAPI CheckNameLegalDOS8Dot3W(const WCHAR*, char*,DWORD,BOOL*,BOOL*);
WINBASEAPI BOOL WINAPI ChangeTimerQueueTimer(HANDLE,HANDLE,ULONG,ULONG);
WINADVAPI BOOL WINAPI CheckTokenMembership(HANDLE,PSID,PBOOL);
WINBASEAPI BOOL WINAPI ClearCommBreak(HANDLE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment