Boosted default block size to 10KB

This commit is contained in:
Andrew S. Rightenburg 2023-04-09 23:35:48 -04:00
parent dd0ec10724
commit 6412fa138c
6 changed files with 9 additions and 9 deletions

View File

@ -45,7 +45,7 @@ polonius-editor sequentially executes editing instructions on a file
-b
--block-size
Specify the maximum amount of data we can load from the file into memory at any given time
Defaults to 1 kilobyte if not specified
Defaults to 10 kilobytes if not specified
Example:

View File

@ -30,7 +30,7 @@ polonius-reader outputs a selected portion of the contents of a file
-b
--block-size
Specify the maximum amount of data we can load from the file into memory at any given time
Defaults to 1 kilobyte if not specified
Defaults to 10 kilobytes if not specified
Example:

View File

@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
string program_author = "rail5";
string helpstring = program_name + " " + program_version + "\nCopyright (C) 2023 " + program_author + "\n\nThis is free software (GNU GPL 3), and you are welcome to redistribute it under certain conditions.\n\nUsage: " + program_name + " -i filename -a \"{INSTRUCTION}\"\n\nOptions:\n -i\n --input\n Specify input file to edit\n\n -a\n --add-instruction\n Instruct the program on how to edit your file\n Example instructions:\n REPLACE 5 hello world\n (Replaces text, starting from byte #5, with \"hello world\")\n INSERT 7 salut a tous\n (Inserts \"salut a tous\" at byte #7, shifting the rest of the file without replacing it)\n REMOVE 9 15\n (Removes bytes #9 to #15 from the file)\n\n -s\n --add-instruction-set\n Provide a set of multiple instructions for editing the file\n Each instruction in the set should be on its own line, as in the following example:\n --add-instruction-set \"REPLACE 20 hello world\n INSERT 50 hello again\n REMOVE 70 75\"\n\n -c\n --special-chars\n Interpret escaped character sequences (\\n, \\t and \\\\)\n\n -b\n --block-size\n Specify the amount of data from the file we're willing to load into memory at any given time\n Example:\n -b 10M\n -b 200K\n (Default 1 kilobyte)\n\n -v\n --verbose\n Verbose mode\n\n -V\n --version\n Print version number\n\n -h\n --help\n Display this message\n\nExamples:\n " + program_name + " --input ./file.txt --add-instruction \"REPLACE 20 hello \\n world\" --add-instruction \"REMOVE 10 12\" --block-size 10K --special-chars\n\n " + program_name + " -a \"insert 0 hello world\" ./file.txt\n";
string helpstring = program_name + " " + program_version + "\nCopyright (C) 2023 " + program_author + "\n\nThis is free software (GNU GPL 3), and you are welcome to redistribute it under certain conditions.\n\nUsage: " + program_name + " -i filename -a \"{INSTRUCTION}\"\n\nOptions:\n -i\n --input\n Specify input file to edit\n\n -a\n --add-instruction\n Instruct the program on how to edit your file\n Example instructions:\n REPLACE 5 hello world\n (Replaces text, starting from byte #5, with \"hello world\")\n INSERT 7 salut a tous\n (Inserts \"salut a tous\" at byte #7, shifting the rest of the file without replacing it)\n REMOVE 9 15\n (Removes bytes #9 to #15 from the file)\n\n -s\n --add-instruction-set\n Provide a set of multiple instructions for editing the file\n Each instruction in the set should be on its own line, as in the following example:\n --add-instruction-set \"REPLACE 20 hello world\n INSERT 50 hello again\n REMOVE 70 75\"\n\n -c\n --special-chars\n Interpret escaped character sequences (\\n, \\t and \\\\)\n\n -b\n --block-size\n Specify the amount of data from the file we're willing to load into memory at any given time\n Example:\n -b 10M\n -b 200K\n (Default 10 kilobytes)\n\n -v\n --verbose\n Verbose mode\n\n -V\n --version\n Print version number\n\n -h\n --help\n Display this message\n\nExamples:\n " + program_name + " --input ./file.txt --add-instruction \"REPLACE 20 hello \\n world\" --add-instruction \"REMOVE 10 12\" --block-size 10K --special-chars\n\n " + program_name + " -a \"insert 0 hello world\" ./file.txt\n";
/*
@ -30,7 +30,7 @@ int main(int argc, char* argv[]) {
bool received_filename = false;
vector<editor::instruction> instructions_to_add;
int block_size = 1024;
int block_size = 10240;
bool interpret_special_chars = false;
bool verbose = false;

View File

@ -66,7 +66,7 @@ namespace editor {
FILE* c_type_file;
int file_descriptor;
int block_size = 1024;
int block_size = 10240;
vector<instruction> instruction_set;
int64_t file_length_after_last_instruction = 0;
@ -107,7 +107,7 @@ namespace editor {
/*
Constructor
*/
file(string path, int blocksize = 1024, bool verbose_mode = false);
file(string path, int blocksize = 10240, bool verbose_mode = false);
};
}

View File

@ -20,7 +20,7 @@ int main(int argc, char* argv[]) {
string program_author = "rail5";
string helpstring = program_name + " " + program_version + "\nCopyright (C) 2023 " + program_author + "\n\nThis is free software (GNU GPL 3), and you are welcome to redistribute it under certain conditions.\n\nUsage: " + program_name + " -i filename\n\nOptions:\n -i\n --input\n Specify input file to read\n\n -s\n --start\n Specify byte number to start reading from\n\n -l\n --length\n Specify how many bytes to read\n\n -b\n --block-size\n Specify the amount of data from the file we're willing to load into memory at any given time\n Example:\n -b 10M\n -b 200K\n (Default 1 kilobyte)\n\n -f\n --find\n --search\n Search for a string in the file\n If -s / --start is specified, the program will only search for matches after that start position\n If -l / --length is specified, the program will only search for matches within that length from the start\n Returns nothing (blank) if no matches were found\n\n -p\n --output-pos\n Output the start and end position, rather than the text (in the format \"start,end\", for example 10,15)\n If used with searches, this will output the start and end position of the search result\n Outside of searches, it will return the values of -s / --start and the end position (start + length)\n\n -V\n --version\n Print version number\n\n -h\n --help\n Display this message\n\nExamples:\n " + program_name + " --input ./file.txt --start 50 --length 10\n\n " + program_name + " -s 50 -l 10 ./file.txt\n\n " + program_name + " -i ./file.txt --start 75 --search \"hello world\" --length 10\n\n " + program_name + " ./file.txt -f \"hello world\" --output-pos\n";
string helpstring = program_name + " " + program_version + "\nCopyright (C) 2023 " + program_author + "\n\nThis is free software (GNU GPL 3), and you are welcome to redistribute it under certain conditions.\n\nUsage: " + program_name + " -i filename\n\nOptions:\n -i\n --input\n Specify input file to read\n\n -s\n --start\n Specify byte number to start reading from\n\n -l\n --length\n Specify how many bytes to read\n\n -b\n --block-size\n Specify the amount of data from the file we're willing to load into memory at any given time\n Example:\n -b 10M\n -b 200K\n (Default 10 kilobytes)\n\n -f\n --find\n --search\n Search for a string in the file\n If -s / --start is specified, the program will only search for matches after that start position\n If -l / --length is specified, the program will only search for matches within that length from the start\n Returns nothing (blank) if no matches were found\n\n -p\n --output-pos\n Output the start and end position, rather than the text (in the format \"start,end\", for example 10,15)\n If used with searches, this will output the start and end position of the search result\n Outside of searches, it will return the values of -s / --start and the end position (start + length)\n\n -V\n --version\n Print version number\n\n -h\n --help\n Display this message\n\nExamples:\n " + program_name + " --input ./file.txt --start 50 --length 10\n\n " + program_name + " -s 50 -l 10 ./file.txt\n\n " + program_name + " -i ./file.txt --start 75 --search \"hello world\" --length 10\n\n " + program_name + " ./file.txt -f \"hello world\" --output-pos\n";
/*
Necessary info for the program to do its job
@ -35,7 +35,7 @@ int main(int argc, char* argv[]) {
int64_t start_position = 0;
int64_t amount_to_read = -1;
int block_size = 1024;
int block_size = 10240;
reader::job_type job = reader::read_job;
string searching_for = "";

View File

@ -19,7 +19,7 @@ namespace reader {
int64_t start_position = 0;
int64_t amount_to_read = -1;
int block_size = 1024;
int block_size = 10240;
string search_query = "";