/* CVS info */ /* $Date: 2005/10/04 17:52:00 $ */ /* $Revision: 1.1 $ */ /* $RCSfile: gen_file.c,v $ */ /* $Name: rel_7 $ */ /* This is a simple program to produce files of a given size. The file is filled with a sequence of lower case letters. File sizes ending in k or K indicate KBytes 1024. File sizes ending in m or M indicate MBytes 1024*1024. */ #include #include // 1 K bytes char data[ 1024 ]; int main(int argc, char** argv){ FILE* File_ptr; char* filename; int fsize; // in KBs int len; int scale = 1; char t; int sh = 1; static char cvs_info[] = "BMARKGRP $Date: 2005/10/04 17:52:00 $ $Revision: 1.1 $ $RCSfile: gen_file.c,v $ $Name: rel_7 $"; // Fill with letters a-z for(int i=0; i<1024; i++){ data[i] = (char)((int)'a'+(i%26)); } filename = argv[1]; if (argc == 2){ fsize = 1; sh = 0; }else{ len = strlen(argv[2]); // KBytes t = argv[2][len-1]; if ( (t=='k') | (t=='K') ){ scale = 1; argv[2][len-1] = 0; sh = 0; } // MBytes if ( (t=='m') | (t=='M') ){ scale = 1024; argv[2][len-1] = 0; sh = 0; } // GBytes if ( (t=='g') | (t=='G') ){ scale = 1024*1024; argv[2][len-1] = 0; sh = 0; } fsize = atoi(argv[2])*scale; } // Open the file for appending if( (File_ptr = fopen(filename, "a") ) == NULL){ printf("open\n"); exit( 2 ); } if (sh){ for (long i=0; i