Created
July 18, 2023 20:57
-
-
Save LBranco27/79ee899556c35dd009f11cac858af273 to your computer and use it in GitHub Desktop.
Change the "L2SD" (used for some reason on lineage 2 music files) to "OggS" on .ogg files. Making it recognizable to common audio players.
This file contains 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
#include <dirent.h> | |
#include <errno.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int main (int argc, char *argv[]) { | |
if (argc == 1){ | |
printf("Usage: convertl2ogg [DIRECTORY]\n"); | |
} | |
DIR* dir = opendir(argv[1]); | |
if (dir) { | |
int file_no = 0; | |
struct dirent *entry; | |
FILE *file; | |
char check[4]; | |
while ((entry=readdir(dir))){ | |
file = fopen(entry->d_name, "r+b"); | |
if(file){ | |
fread(check, 1, 4, file); | |
if ((strcmp(check, "L2SD")) == 0){ | |
fseek(file, 0, SEEK_SET); | |
fwrite("OggS", sizeof(char), 4, file); | |
file_no++; | |
} | |
fclose(file); | |
} | |
} | |
printf("%d files changed\n", file_no); | |
closedir(dir); | |
} else if (ENOENT == errno) { | |
printf("Error: %d\n", errno); | |
} else { | |
printf("Unknown error\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment