mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-12-02 23:14:23 +01:00
Extract the basename for use in our output filenames...
This commit is contained in:
parent
cc0d75400a
commit
d51df5f9a2
@ -11,6 +11,21 @@ void PrintUsage() {
|
|||||||
fprintf(stderr, "Usage: tc [-l] [-q <quality>] [-n <num>] [-simd] [-t <threads> [-j <jobs>]] <imagefile>\n");
|
fprintf(stderr, "Usage: tc [-l] [-q <quality>] [-n <num>] [-simd] [-t <threads> [-j <jobs>]] <imagefile>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExtractBasename(const char *filename, char *buf, int bufSz) {
|
||||||
|
int len = strlen(filename);
|
||||||
|
const char *end = filename + len;
|
||||||
|
while(--end != filename) {
|
||||||
|
if(*end == '.')
|
||||||
|
{
|
||||||
|
int numChars = end - filename + 1;
|
||||||
|
int toCopy = (numChars > bufSz)? bufSz : numChars;
|
||||||
|
memcpy(buf, filename, toCopy);
|
||||||
|
buf[toCopy - 1] = '\0';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
int fileArg = 1;
|
int fileArg = 1;
|
||||||
@ -109,6 +124,9 @@ int main(int argc, char **argv) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char basename[256];
|
||||||
|
ExtractBasename(argv[fileArg], basename, 256);
|
||||||
|
|
||||||
ImageFile file (argv[fileArg]);
|
ImageFile file (argv[fileArg]);
|
||||||
if(!file.Load()) {
|
if(!file.Load()) {
|
||||||
fprintf(stderr, "Error loading file: %s\n", argv[fileArg]);
|
fprintf(stderr, "Error loading file: %s\n", argv[fileArg]);
|
||||||
@ -146,11 +164,11 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(bSaveLog) {
|
if(bSaveLog) {
|
||||||
statManager->ToFile(strcat(argv[fileArg], ".log"));
|
statManager->ToFile(strcat(basename, ".log"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Image cImg (*ci);
|
Image cImg (*ci);
|
||||||
ImageFile cImgFile (strcat(argv[fileArg], "-bc7.png"), eFileFormat_PNG, cImg);
|
ImageFile cImgFile (strcat(basename, "-bc7.png"), eFileFormat_PNG, cImg);
|
||||||
cImgFile.Write();
|
cImgFile.Write();
|
||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
|
Loading…
Reference in New Issue
Block a user