Skip to content

Instantly share code, notes, and snippets.

@tyranid
Created June 2, 2014 21:42
Show Gist options
  • Save tyranid/27dd557ed04c6b980f8a to your computer and use it in GitHub Desktop.
Save tyranid/27dd557ed04c6b980f8a to your computer and use it in GitHub Desktop.
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