Open retrosapien opened 2 days ago
I tried to just redirect stdout to /dev/null, but it looks like all errors are printed on stdout, too! Should they not be printed to stderr?
Looks like the error messages just needs to be changed from;
printf("Error: ...
to fprintf(stderr, "Error:...
Can change all error messages with these; To see what will be changed;
$ sed -n "s/printf(\\"Error/fprintf(stderr, \\"Error/gp" iso2opl.c
fprintf(stderr, "Error: failed to open ISO file: %s\n", isofile);
fprintf(stderr, "Error: can't open SYSTEM.CNF from ISO file: %s\n", isofile);
fprintf(stderr, "Error: failed to read SYSTEM.CNF from ISO file: %s\n", isofile);
fprintf(stderr, "Error: failed to parse SYSTEM.CNF from ISO file: %s\n", isofile);
fprintf(stderr, "Error: failed to locate elf path from ISO file: %s\n", isofile);
fprintf(stderr, "Error: a game with the same ID is already installed on drive!\n");
fprintf(stderr, "Error: can't read ul.cfg on drive!\n");
fprintf(stderr, "Error: failed to allocate memory to read ISO!\n");
fprintf(stderr, "Error: game part creation failed!\n");
fprintf(stderr, "Error: failed to read datas from ISO file!\n");
fprintf(stderr, "Error: failed to write datas to part file!\n");
fprintf(stderr, "Error: can't open ul.cfg!\n");
fprintf(stderr, "Error: write to ul.cfg failed!\n");
Then use this to edit the file;
$ sed -i "s/printf(\\"Error/fprintf(stderr, \\"Error/g" iso2opl.c
Compiled and ran as expected! Can now redirect stdout to /dev/null without missing error messeges.
But i also noticed there is no error message for using a [GAME_NAME] greater than 32 characters. It just outputs the usage message.
Found this in iso2opl.c;
if ((argc < 5) || (strcmp(argv[4], "CD") && strcmp(argv[4], "DVD")) || (strlen(argv[3]) > 32)) {
printUsage();
exit(EXIT_FAILURE);
I think it is checking string length of argv 3 -> the GAME_NAME, but this should have a dedicated error message, since the usage message does not mention the 3-32 character requirement. If it did, i guess printing the usage message would be fine.
this line in iso2opl.c is all that needs to be changed. (I mistakenly said there is two, below. The first is in a comment block. I initially didn't have colours on in my editor and missed that.)
change the /n to a /r and add a fflush(sdtout), so;
and a new line added after the file is closed;
TL;DR
Can you add an option to make this less/more verbose?
I'm specifically interested in this line; Writing 256 sectors to /home/user/ul.AB6C56EC.SLUS_218.65.01 - LBA: 4162559 Writing 256 sectors to /home/user/ul.AB6C56EC.SLUS_218.65.01 - LBA: 4162815 ...
Can this line be updated inplace until it is finished writing so that it never takes more than one line in the terminal? Maybe use a pause and reset combo or something?
Something like this after the printf(...
Above found here; https://www.geeksforgeeks.org/clear-console-c-language/ The printf(regex... is supposed to be the fastest.
I found these two lines in iso2opl.c that i think are relevant;
Maybe add that regex after those lines?
That change made an error during compile;
Tried with;
returned;
Trying with;
Last one works, but need a sleep command or it clears too fast to read any thing.
Moved the system("clear"); before the printf( "Writing... line, and added a sleep(2);
Success!
Here is how i edited the file;
The text is the same on both lines, just the indenting is different. Actually, the sleep command is not even needed. Just change to;
The only thing i don't like is that it clears the whole screen. I would prefer if it only cleared that line. But at least it works.