📄 tolower.cpp
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "..\..\3DLib\define.h"
#include "..\..\3DLib\inline.h"
#include "..\..\3DLib\FileIO.h"
#include "opcode.h"
#include "record.h"
#include "fltutil.h"
void main (int argc, char *argv[])
{
if (argc < 3) {
puts ("\nToLower v1.0 by Erick Jap\n");
puts ("Usage: ToLower inputfile outputfile [basename]");
exit (1);
}
char infile[80], outfile[80], basename[80], temp[256];
glConcatFileExtension ((GLbyte *) infile, (GLbyte *) argv[1], (GLbyte *) "FLT");
glConcatFileExtension ((GLbyte *) outfile, (GLbyte *) argv[2], (GLbyte *) "FLT");
basename[0] = '\0';
if (argc > 3) {
strcpy (basename, argv[3]);
strlwr (basename);
}
int baselen = strlen (basename);
CFileIO myfile;
if (!myfile.openread (infile)) {
printf ("Can not open input file %s\n", infile);
exit (1);
}
if (!myfile.openwrite (outfile, 1)) {
printf ("Can not open output file %s\n", outfile);
exit (1);
}
printf ("Converting name to lowercase...");
while (!myfile.eof()) {
short rtype = myfile.read_short ();
myfile.writedata ((char *) &rtype, 2);
short rlen = myfile.read_short ();
myfile.writedata ((char *) &rlen, 2);
short rectype = swap_short (rtype);
short reclen = swap_short (rlen);
reclen -= 4;
if (reclen > 0) {
char *buf = (char *) glAllocateMemory (reclen);
if (!buf) {
printf ("Error allocating memory!\n");
exit (1);
}
myfile.readdata (buf, reclen);
if (rectype == OPCODE_TEXTURE_REFERENCE_RECORD) {
strlwr (buf);
}
else if (rectype == OPCODE_EXTERNAL_REFERENCE) {
strlwr (buf);
if (!strncmp (buf, basename, baselen)) {
strcpy (temp, buf + baselen);
strcpy (buf, temp);
}
}
myfile.writedata (buf, reclen);
glReleaseMemory (buf);
}
}
printf ("\nDone.\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -