参考资源:LR帮助
Action()
{
int count,total=0,i;
char buffer[1000];
long file_stream;
char filename[1024], command[1024],line[100];
char new_dir[] = "C:\\test";
if (mkdir(new_dir))
lr_output_message("Create directory %s failed", new_dir);
else
lr_output_message("Created new directory %s", new_dir);
sprintf (filename, "%s\\%s", new_dir, "newfile.txt");
sprintf (command, "dir /b c:\\ > %s /w", filename );
system(command);
lr_output_message("Created new file %s", filename);
if((file_stream=fopen(filename,"r"))==NULL)
{
lr_error_message("can not open %s",filename);
return -1;
}
for(i=1;i<10;i++)
{
if (fgets(line, 100, file_stream) == NULL)
lr_output_message("fgets error" );
else
lr_output_message( "The first line is \"%s\"", line);
}
while(!feof(file_stream))
{
count=fread(buffer,sizeof(char),1000,file_stream);
lr_output_message("%3d read",count);
if(ferror(file_stream))
{
lr_output_message("error reading file %s",filename);
break;
}
total+=count;
}
lr_output_message("Total number of bytes read = %d",total);
if(fclose(file_stream))
lr_error_message("Error closing file %s",filename);
return 0;
} |
Action()
{
char command[1024];
sprintf(command,"java -javaagent:D:\testtools\Mercury\MercuryDiagnostics\JAVAProbe\lib\probeagent.jar" );
system(command);
return 0;
} |