Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Test Case for Illegal NTFS Names
#include <stdio.h>
#include <tchar.h>
#include <Windows.h>
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 1; i < 128; ++i)
{
std::wstring name = L".\a";
name += (WCHAR)i;
name += L"a";
HANDLE hFile = CreateFile(name.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE, NULL, CREATE_ALWAYS, FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("Illegal Char: %d\n", i);
}
else
{
CloseHandle(hFile);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.