#include #include #include /* When Steve Bourne was writing his Unix shell (which came to be known as the Bourne shell), he made a directory of 254 files with one-character names, one for each byte value except '\0' and slash, the two characters that cannot appear in Unix file names. He used that directory for all manner of tests of pattern-matching and tok- enization. (The test directory was of course created by a program.) For years after- wards, that directory was the bane of file-tree-walking programs; it tested them to destruction. The Practice of Programming - p158 */ int main( int argc, char** argv ) { unsigned char f,filename[2]; filename[1]='\0'; if( argc<2 ) { printf("Usage: %s directory\n",argv[0]); printf("\tThis program will create all valid one-character filenames in the specified directory.\n"); return 1; } if( chdir(argv[1]) ) { fprintf(stderr, "%s is not a directory\n", argv[1]); return 1; } for( f=1; f<=255; f++) { // exclude '/' and '.' as they are not valid filenames on most file systems if(f!='/' && f!='.') { filename[0] = f; fclose(fopen(filename,"w")); } /* break to not overflow the char */ if( f == 0xff ) break; } return 0; }