Idea Transcript
About
Services
Products
Partners
Resources
Support
Contact
/* Writes a string to the end of a file. Arguments: - file_name: Include the full path in the file name, and escape any slashes. E.g. "C:\\TEMP\\output.txt". Note that file does not have to exist beforehand, but directory does. - string: If attempting to write a single line, include a newline character at the end of the string. Returns 0 on success. On failure, function will raise lr_error_message and return -1. */ int jds_append_to_file(char* file_name, char* string) { int fp; // file pointer int rc; // return code int length = strlen(string); // Check that file_name is not NULL. if (file_name == NULL) { lr_error_message("Error. File name is NULL"); return -1; } fp = fopen(file_name, "a"); // open file in "append" mode. if (fp == NULL) { lr_error_message("Error opening file: %s", file_name); return -1; } rc = fprintf(fp, "%s", string); if (rc != length) { lr_error_message("Error writing to file: %s", file_name); return -1; } rc = fclose(fp); if (rc != 0) { lr_error_message("Error closing file: %s", file_name); return -1; } return 0; }
// Checks if a file already exists on the filesystem. // Arguments: // - file_name: Include the full path in the file name. // Returns TRUE (1) if file exists and user has read access to the file, otherwise function returns FALSE (0). int jds_file_exists(char* file_name) { int fp; // file pointer fp = fopen(file_name, "r+"); // open file in read mode. File must already exist. if (fp == NULL) { return FALSE; } else { fclose(fp); return TRUE; } }
// Saves a file to the hard disk. // Arguments: // - file_name: Include the full path in the file name. Note that file must not exist before function is called. // - file_content: The RB/BIN=", "Search=Body", LAST); // Note that it is best to use web_custom_request, as this guarantees that only one file is being downloaded by this step. web_custom_request("DownloadPlugin", "URL=http://www.example.com/files/test.zip", "Method=GET", "Resource=1", "RecContentType=text/css", "Referer=https://www.jds.net.au", "Snapshot=t1.inf", LAST); // returns the size of the previous HTTP response size = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE); jds_save_file(file, lr_eval_string("{FileContents}"), size); return 0; }
web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
int fp; // filestream pointer int sz; // file size fp = fopen("E:\\LoadRunner\\Scripts\\bet365.zip", "r+b"); // open in binary mode (read-only). File must exist. fseek(fp, 0, SEEK_END); // sets the position indicator associated with the stream to the end of the file. sz = ftell(fp); // standard C function to return the current value of the position indicator of the stream. For binary streams, this is the number of bytes from the beginning of the file. This function is undocumented in the VuGen help file. lr_output_message("size: %d", sz); // size in bytes
//Creates a directory using the given path name. int mkdir ( const char *path );
Enter your comment here...