Subversion Repositories spk

Rev

Rev 290 | Rev 325 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 290 Rev 304
Line 16... Line 16...
16
#include <direct.h>
16
#include <direct.h>
17
#include <shlobj.h>
17
#include <shlobj.h>
18
#endif
18
#endif
19
 
19
 
20
#include "sndfile.hh"
20
#include "sndfile.hh"
-
 
21
#include "Utils/CommandLine.h"
21
 
22
 
22
 
23
 
23
void PrintSyntax (const Utils::WString &cmd)
24
void PrintSyntax (const Utils::WString &cmd)
24
{	
25
{	
25
	wprintf ( L"Syntax: %s </command> [options]\n", cmd.c_str());
26
	wprintf ( L"Syntax: %s </command> [options]\n", cmd.c_str());
Line 52... Line 53...
52
}
53
}
53
 
54
 
54
#define BUFFER_LEN 4096
55
#define BUFFER_LEN 4096
55
 
56
 
56
 
57
 
57
void DoOffset(const Utils::WString &cmd, const Utils::WStringList &options, const std::vector<Utils::WString> &args)
58
void DoOffset(const Utils::CommandLine &cmd)
58
{
59
{
59
	if (args.size() < 2)
60
	if (cmd.argCount() < 3)
60
	{
61
	{
61
		wprintf(L"Syntax: %s offset [options] <offset> <file> [--out:<file>]\n", cmd.c_str());
62
		wprintf(L"Syntax: %s offset [options] <offset> <file> [--out:<file>]\n", cmd.cmdName().c_str());
62
		wprintf(L"	<offset>\t\tOffset time to adjust by\n");
63
		wprintf(L"	<offset>\t\tOffset time to adjust by\n");
63
		wprintf(L"	<file>\t\tThe file to adjust\n");
64
		wprintf(L"	<file>\t\tThe file to adjust\n");
64
		wprintf(L"\nOptions:\n");
65
		wprintf(L"\nOptions:\n");
65
		wprintf(L"  --out:<file>\t\tThe output filename, otherwise, will write to the input\n");
66
		wprintf(L"  --out:<file>\t\tThe output filename, otherwise, will write to the input\n");
66
		wprintf(L"  --page:<id>\t\tThe page id to read (otherwise will do all of them)\n");
67
		wprintf(L"  --page:<id>\t\tThe page id to read (otherwise will do all of them)\n");
67
	}
68
	}
68
	else
69
	else
69
	{
70
	{
70
		Utils::WString offsetStr = args[0];
71
		Utils::WString offsetStr = cmd.arg(1);
71
		Utils::WString fileStr = args[1];
72
		Utils::WString fileStr = cmd.arg(2);
72
		Utils::WString outFileStr = options.contains(L"out") ? options[L"out"]->data : fileStr;
73
		Utils::WString outFileStr = cmd.hasSwitch(L"out") ? cmd.switchData(L"out") : fileStr;
73
		unsigned int pageID = options.contains(L"page") ? options[L"page"]->data.toInt() : 0;
74
		unsigned int pageID = cmd.hasSwitch(L"page") ? cmd.switchData(L"page").toInt() : 0;
74
		long offset = offsetStr.toLong();
75
		long offset = offsetStr.toLong();
75
		bool doIgnore = options.contains(L"ignore");
76
		bool doIgnore = cmd.hasSwitch(L"ignore");
76
 
77
 
77
		CFileIO f;
78
		CFileIO f;
78
		if (f.open(fileStr))
79
		if (f.open(fileStr))
79
		{
80
		{
80
			bool inPage = false;
81
			bool inPage = false;
Line 132... Line 133...
132
int main ( int argc, char **argv )
133
int main ( int argc, char **argv )
133
{
134
{
134
 	// display program header to command prompt
135
 	// display program header to command prompt
135
	printf ( "\nX3 Voice Create V1.00 (SPK Library Version %.2f) 15/12/2023 Created by Cycrow\n\n", GetLibraryVersion() );
136
	printf ( "\nX3 Voice Create V1.00 (SPK Library Version %.2f) 15/12/2023 Created by Cycrow\n\n", GetLibraryVersion() );
136
 
137
 
137
	// parse the cmd name
-
 
138
	Utils::WString cmd (argv[0]);
138
	Utils::CommandLine cmd(argc, argv);
139
	Utils::WString command(argc > 1 ? argv[1] : "");
139
	Utils::WString command = cmd.argCount() >= 1 ? cmd.arg(0) : L"";
140
	cmd = cmd.findReplace(L"\\", L"/");
-
 
141
	Utils::WString cmdDir = cmd.tokens(L"/", 1, cmd.countToken(L"/") - 1);
-
 
142
	cmd = cmd.token(L"/", cmd.countToken(L"/"));
-
 
143
 
-
 
144
	Utils::WStringList options;
-
 
145
	std::vector<Utils::WString> args;
-
 
146
	for (int i = 2; i < argc; i++)
-
 
147
	{
-
 
148
		Utils::WString arg(argv[i]);
-
 
149
		if (arg.startsWith(L"--"))
-
 
150
		{
-
 
151
			arg = arg.substr(2);
-
 
152
 
-
 
153
			if (arg.contains(L":"))
-
 
154
			{
-
 
155
				Utils::WString a = arg.token(L":", 1);
-
 
156
				Utils::WString b = arg.tokens(L":", 2);
-
 
157
				options.pushBack(a, b);
-
 
158
			}
-
 
159
			else
-
 
160
				options.pushBack(arg);
-
 
161
		}
-
 
162
		else
-
 
163
			args.push_back(arg);
-
 
164
	}
-
 
165
 
140
 
166
	if (command == L"offset")
141
	if (command == L"offset")
167
		DoOffset(cmd, options, args);
142
		DoOffset(cmd);
168
	else if (command == L"help")
143
	else if (command == L"help")
169
	{
-
 
170
		PrintSyntax(cmd);
144
		PrintSyntax(cmd.cmdName());
171
	}
-
 
172
	else
145
	else
173
	{
146
	{
174
 
147
 
175
		Utils::String mainFileStr = "d:/x/X3 Terran Conflict - Guilds/addon2/mov/00344.wav";
148
		Utils::String mainFileStr = "d:/x/X3 Terran Conflict - Guilds/addon2/mov/00344.wav";
176
		Utils::WString dir = L"d:/x/X3 Terran Conflict - Guilds/addon2/mov/working";
149
		Utils::WString dir = L"d:/x/X3 Terran Conflict - Guilds/addon2/mov/working";