Last active
January 16, 2026 10:42
-
-
Save LightningStalker/e87083feceb11329c66b94f18da60c8d to your computer and use it in GitHub Desktop.
Pass files list to mksquashfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* wrapper prog for mksquashfs | |
| * to add the missing file list functions | |
| * because xargs have lousy quoting and and shell script also suck | |
| * beware of the MAX_INPUT limit of the shell | |
| * Project Crew™ 1/15/2026 | |
| */ | |
| #include <iostream> | |
| #include <fstream> | |
| using namespace std; | |
| #define BAKPROG "mksquashfs" | |
| #define BAKFILE "backup.sfs" | |
| #define OPTIONS "-comp xz -processors 13" | |
| int main() | |
| { | |
| string list, cmd, filename = "filelist"; | |
| // open file for reading like at McDonald's | |
| ifstream istrm(filename, ios::binary); | |
| if (!istrm.is_open()) | |
| { | |
| cerr << "backup: \e[1;38;5;196merror:\e[0m failed to open " | |
| "the file: <\e[1;33m" | |
| << filename << "\e[0m>" << endl; | |
| exit(EXIT_FAILURE); | |
| } | |
| else | |
| { | |
| string line; | |
| cout << "backup: reading paths and files from list file..." << endl; | |
| while (getline(istrm, line)) // generate list | |
| { | |
| list += "'" + line + "' "; | |
| //cout << "backup: read back from file: " << line << '\n'; | |
| } | |
| //cout << list << "\n\n"; | |
| } | |
| if(list.size() < 2) | |
| { | |
| cerr << "backup: \e[1;38;5;196merror:\e[0m empty list file, nothing do" | |
| << endl; | |
| exit(2); | |
| } | |
| /* build the command */ | |
| cout << "backup: building command line..." << endl; | |
| cmd = BAKPROG; | |
| /* had to split the line because of some kind of compiler bug | |
| * or SOMETHING */ | |
| cmd += ' ' + list + BAKFILE + ' ' + OPTIONS; | |
| cout << "backup: backup command: $ "; | |
| cout << cmd << endl; | |
| cout << "backup: begin backup operation..." << endl; | |
| int chilret = system(cmd.data()); | |
| if (!chilret) | |
| { | |
| cout << endl << "backup: completed successfully" << endl; | |
| cout << "\e[1;38;5;196mYOU SHOULD RENAME " << BAKFILE << "!\e[0m" << endl; | |
| }else | |
| { | |
| cerr << "backup: \e[1;38;5;196merror known:\e[0m the child " | |
| << "\e[1;32m" << BAKPROG | |
| << "\e[0m exited status \e[1;37m" << chilret << "\e[0m" << endl; | |
| exit(3); | |
| } | |
| return(EXIT_SUCCESS); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment