port from perforce
This commit is contained in:
20
evoke-64k/trunk/filemon/filemon.sln
Normal file
20
evoke-64k/trunk/filemon/filemon.sln
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "filemon", "filemon\filemon.vcproj", "{70D5E87D-2967-4355-8D64-AD7AA82A149C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{70D5E87D-2967-4355-8D64-AD7AA82A149C}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{70D5E87D-2967-4355-8D64-AD7AA82A149C}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{70D5E87D-2967-4355-8D64-AD7AA82A149C}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{70D5E87D-2967-4355-8D64-AD7AA82A149C}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
evoke-64k/trunk/filemon/filemon/Debug/BuildLog.htm
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Debug/BuildLog.htm
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Debug/compiler.obj
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Debug/compiler.obj
Normal file
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="win32" name="Microsoft.VC90.DebugCRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type='win32' name='Microsoft.VC90.DebugCRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
BIN
evoke-64k/trunk/filemon/filemon/Debug/filemon.g.obj
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Debug/filemon.g.obj
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Debug/filemon.obj
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Debug/filemon.obj
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Debug/filemon.pch
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Debug/filemon.pch
Normal file
Binary file not shown.
1
evoke-64k/trunk/filemon/filemon/Debug/mt.dep
Normal file
1
evoke-64k/trunk/filemon/filemon/Debug/mt.dep
Normal file
@@ -0,0 +1 @@
|
||||
Manifest resource last updated at 22:04:31,43 on 01.06.2010
|
||||
BIN
evoke-64k/trunk/filemon/filemon/Debug/vc90.idb
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Debug/vc90.idb
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Debug/vc90.pdb
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Debug/vc90.pdb
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Release/BuildLog.htm
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Release/BuildLog.htm
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Release/compiler.obj
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Release/compiler.obj
Normal file
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
BIN
evoke-64k/trunk/filemon/filemon/Release/filemon.g.obj
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Release/filemon.g.obj
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Release/filemon.obj
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Release/filemon.obj
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Release/filemon.pch
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Release/filemon.pch
Normal file
Binary file not shown.
1
evoke-64k/trunk/filemon/filemon/Release/mt.dep
Normal file
1
evoke-64k/trunk/filemon/filemon/Release/mt.dep
Normal file
@@ -0,0 +1 @@
|
||||
Manifest resource last updated at 22:01:44,58 on 01.06.2010
|
||||
BIN
evoke-64k/trunk/filemon/filemon/Release/stdafx.obj
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Release/stdafx.obj
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Release/vc90.idb
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Release/vc90.idb
Normal file
Binary file not shown.
BIN
evoke-64k/trunk/filemon/filemon/Release/vc90.pdb
Normal file
BIN
evoke-64k/trunk/filemon/filemon/Release/vc90.pdb
Normal file
Binary file not shown.
112
evoke-64k/trunk/filemon/filemon/compiler.cpp
Normal file
112
evoke-64k/trunk/filemon/filemon/compiler.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#include "filemon.h"
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <Shlwapi.h>
|
||||
|
||||
#define COMPILER_OUT(text) line = text; fwrite(line.c_str(), 1, line.length(), file)
|
||||
|
||||
#include "test.txt"
|
||||
#ifndef FILEMON_ACTIVE
|
||||
int ParseDir(const std::string& dir);
|
||||
#endif
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
#ifndef FILEMON_ACTIVE
|
||||
if (argc <= 2)
|
||||
{
|
||||
std::cout << "filemon: Not enough arguments provided. Usage: filemon [DIR] [OUTPUT]. argc == " << argc << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!PathIsDirectory(argv[1]))
|
||||
{
|
||||
std::cout << "filemon: Provided argument 1 is not an existing directory: " << argv[1] << std::endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
int result = ParseDir(argv[1]);
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
FILE* file;
|
||||
fopen_s(&file, argv[2], "wt");
|
||||
if (file == NULL)
|
||||
return 4;
|
||||
|
||||
std::string line;
|
||||
COMPILER_OUT("// NOTE: This is an autogenerated file, don't bother editing...\n");
|
||||
COMPILER_OUT("#include \"filemon.h\"\n");
|
||||
COMPILER_OUT("#include <windows.h>\n");
|
||||
COMPILER_OUT("\n");
|
||||
COMPILER_OUT("#ifdef FILEMON_ACTIVE\n");
|
||||
COMPILER_OUT("\n");
|
||||
COMPILER_OUT("std::map<std::string, std::string> g_VariableTypes;\n");
|
||||
COMPILER_OUT("std::map<std::string, std::string> g_VariableDefaultValues;\n");
|
||||
COMPILER_OUT("std::map<int, std::string> g_FilesToMonitor;\n");
|
||||
COMPILER_OUT("std::map<std::string, void*> g_Variables;\n");
|
||||
COMPILER_OUT("\n");
|
||||
for (std::map<std::string, std::string>::iterator iter = g_VariableTypes.begin(); iter != g_VariableTypes.end(); ++iter)
|
||||
{
|
||||
COMPILER_OUT(iter->second);
|
||||
COMPILER_OUT(" ");
|
||||
COMPILER_OUT(iter->first);
|
||||
COMPILER_OUT(" = ");
|
||||
COMPILER_OUT(g_VariableDefaultValues[iter->first]);
|
||||
COMPILER_OUT(";\n");
|
||||
}
|
||||
COMPILER_OUT("\n");
|
||||
COMPILER_OUT("void InitFileMon()\n");
|
||||
COMPILER_OUT("{\n");
|
||||
for (std::map<std::string, std::string>::iterator iter = g_VariableTypes.begin(); iter != g_VariableTypes.end(); ++iter)
|
||||
{
|
||||
COMPILER_OUT("\tg_Variables[\"");
|
||||
COMPILER_OUT(iter->first);
|
||||
COMPILER_OUT("\"] = &");
|
||||
COMPILER_OUT(iter->first);
|
||||
COMPILER_OUT(";\n");
|
||||
}
|
||||
COMPILER_OUT("\n");
|
||||
COMPILER_OUT("\tfor (unsigned int i = 0; i < g_FilesToMonitor.size(); ++i)\n");
|
||||
COMPILER_OUT("\t{\n");
|
||||
COMPILER_OUT("\t\tParseFile(g_FilesToMonitor[i]);\n");
|
||||
COMPILER_OUT("\t\t::CreateThread(NULL, NULL, MonitorFile, (void*)(int)i, NULL, NULL);\n");
|
||||
COMPILER_OUT("\t}\n");
|
||||
COMPILER_OUT("}\n");
|
||||
COMPILER_OUT("#else\n");
|
||||
COMPILER_OUT("void InitFileMon() {}\n");
|
||||
COMPILER_OUT("#endif\n");
|
||||
|
||||
fclose(file);
|
||||
|
||||
#else
|
||||
if (argc <= 1)
|
||||
{
|
||||
std::cout << "filemon: Not enough arguments provided. Usage: filemon [DIR]. argc == " << argc << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int result = ParseDir(argv[1]);
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
||||
InitFileMon();
|
||||
do
|
||||
{
|
||||
for (std::map<std::string, void*>::iterator iter = g_Variables.begin(); iter != g_Variables.end();)
|
||||
{
|
||||
std::cout << iter->first.c_str() << " = ";
|
||||
if (g_VariableTypes[iter->first] == "int")
|
||||
std::cout << *((int*)iter->second);
|
||||
if (g_VariableTypes[iter->first] == "bool")
|
||||
std::cout << (*((bool*)iter->second) ? "true" : "false");
|
||||
if (g_VariableTypes[iter->first] == "float")
|
||||
std::cout << *((float*)iter->second);
|
||||
if (++iter == g_Variables.end()) std::cout << std::endl; else std::cout << ", ";
|
||||
}
|
||||
::Sleep(1000);
|
||||
} while (!::GetAsyncKeyState(VK_ESCAPE));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
390
evoke-64k/trunk/filemon/filemon/filemon.cpp
Normal file
390
evoke-64k/trunk/filemon/filemon/filemon.cpp
Normal file
@@ -0,0 +1,390 @@
|
||||
#include "filemon.h"
|
||||
#include <io.h>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
void TrimLeft(std::string& str, const char* chars2remove)
|
||||
{
|
||||
if (!str.empty())
|
||||
{
|
||||
std::string::size_type pos = str.find_first_not_of(chars2remove);
|
||||
|
||||
if (pos != std::string::npos)
|
||||
str.erase(0,pos);
|
||||
else
|
||||
str.erase( str.begin() , str.end() ); // make empty
|
||||
}
|
||||
}
|
||||
|
||||
void TrimRight(std::string& str, const char* chars2remove)
|
||||
{
|
||||
if (!str.empty())
|
||||
{
|
||||
std::string::size_type pos = str.find_last_not_of(chars2remove);
|
||||
|
||||
if (pos != std::string::npos)
|
||||
str.erase(pos+1);
|
||||
else
|
||||
str.erase( str.begin() , str.end() ); // make empty
|
||||
}
|
||||
}
|
||||
|
||||
std::string Trim(std::string& str, const char* chars2remove)
|
||||
{
|
||||
std::string temp = str;
|
||||
TrimLeft(temp, chars2remove);
|
||||
TrimRight(temp, chars2remove);
|
||||
return temp;
|
||||
}
|
||||
|
||||
struct AnyParam
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
struct ComboParam : AnyParam
|
||||
{
|
||||
ComboParam(const std::string& options)
|
||||
: AnyParam()
|
||||
, m_Options(options)
|
||||
{
|
||||
}
|
||||
|
||||
std::string m_Options;
|
||||
};
|
||||
|
||||
|
||||
struct RangeParam : AnyParam
|
||||
{
|
||||
RangeParam(const std::string& from, const std::string& to)
|
||||
: AnyParam()
|
||||
, m_From(from)
|
||||
, m_To(to)
|
||||
{
|
||||
}
|
||||
|
||||
std::string m_From;
|
||||
std::string m_To;
|
||||
};
|
||||
|
||||
#ifndef FILEMON_ACTIVE
|
||||
std::map<std::string, std::string> g_VariableTypes;
|
||||
std::map<std::string, std::string> g_VariableDefaultValues;
|
||||
std::map<int, std::string> g_FilesToMonitor;
|
||||
std::map<std::string, void*> g_Variables;
|
||||
#endif
|
||||
std::map<std::string, AnyParam*> g_VariableParams;
|
||||
std::map<std::string, int> g_LineNumber;
|
||||
std::map<int, __time64_t> g_FileChangedDate;
|
||||
|
||||
|
||||
char* TextFileRead(const std::string& as_FileName)
|
||||
{
|
||||
FILE* lh_File;
|
||||
char* ls_Content_ = NULL;
|
||||
size_t li_Count = 0;
|
||||
|
||||
if (as_FileName.empty())
|
||||
{
|
||||
throw "Error: No file to parse!";
|
||||
}
|
||||
|
||||
fopen_s(&lh_File, as_FileName.c_str(), "rt");
|
||||
if (lh_File == NULL)
|
||||
{
|
||||
std::string ls_Message = "Error: Can't open ";
|
||||
ls_Message += as_FileName;
|
||||
throw ls_Message.c_str();
|
||||
}
|
||||
|
||||
fseek(lh_File, 0, SEEK_END);
|
||||
li_Count = ftell(lh_File);
|
||||
rewind(lh_File);
|
||||
|
||||
if (li_Count <= 0)
|
||||
{
|
||||
std::string ls_Message = "Error: File ";
|
||||
ls_Message += as_FileName;
|
||||
ls_Message += " was empty or returned negative file size!";
|
||||
throw ls_Message.c_str();
|
||||
}
|
||||
|
||||
ls_Content_ = new char[li_Count + 1];
|
||||
li_Count = fread_s(ls_Content_, li_Count + 1, sizeof(char), li_Count, lh_File);
|
||||
ls_Content_[li_Count] = 0;
|
||||
|
||||
fclose(lh_File);
|
||||
|
||||
return ls_Content_;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Macros:
|
||||
|
||||
ANY(type) name = value;
|
||||
RANGE(type, from, to) name = value;
|
||||
COMBO(type, "value1, value2, ..., valueN") name = value;
|
||||
|
||||
Types:
|
||||
float, int, bool
|
||||
*/
|
||||
|
||||
|
||||
void ParseLine(std::string line, int lineNumber)
|
||||
{
|
||||
if (line.at(0) == '#' || line.at(0) == '/')
|
||||
return;
|
||||
|
||||
std::string string, macro, type, from, to, options, name, value;
|
||||
|
||||
if (line.substr(0, 3) == "ANY")
|
||||
{
|
||||
string = line.substr(3, line.length() - 3);
|
||||
macro = "ANY";
|
||||
}
|
||||
else if (line.substr(0, 5) == "RANGE")
|
||||
{
|
||||
string = line.substr(5, line.length() - 5);
|
||||
macro = "RANGE";
|
||||
}
|
||||
else if (line.substr(0, 5) == "COMBO")
|
||||
{
|
||||
string = line.substr(5, line.length() - 5);
|
||||
macro = "COMBO";
|
||||
}
|
||||
|
||||
if (macro.length() == 0)
|
||||
return;
|
||||
|
||||
if (string.at(0) != '(')
|
||||
return;
|
||||
|
||||
string = string.substr(1, line.length() - 1);
|
||||
|
||||
if (string.substr(0, 3) == "int")
|
||||
{
|
||||
string = string.substr(3, line.length() - 3);
|
||||
type = "int";
|
||||
}
|
||||
else if (string.substr(0, 4) == "bool")
|
||||
{
|
||||
string = string.substr(4, line.length() - 4);
|
||||
type = "bool";
|
||||
}
|
||||
else if (string.substr(0, 5) == "float")
|
||||
{
|
||||
string = string.substr(5, line.length() - 5);
|
||||
type = "float";
|
||||
}
|
||||
|
||||
if (type.length() == 0)
|
||||
return;
|
||||
|
||||
if (macro == "RANGE")
|
||||
{
|
||||
string = Trim(string, " \t");
|
||||
|
||||
if (string.at(0) != ',')
|
||||
return;
|
||||
string = string.substr(1, line.length() - 1);
|
||||
|
||||
string = Trim(string, " \t");
|
||||
|
||||
int pos = string.find(',');
|
||||
if (pos == -1)
|
||||
return;
|
||||
|
||||
from = Trim(string.substr(0, pos), " \t");
|
||||
string = Trim(string.substr(pos, line.length() - pos), " \t");
|
||||
|
||||
if (string.at(0) != ',')
|
||||
return;
|
||||
string = string.substr(1, line.length() - 1);
|
||||
|
||||
string = Trim(string, " \t");
|
||||
|
||||
pos = string.find(',');
|
||||
if (pos == -1)
|
||||
return;
|
||||
|
||||
to = Trim(string.substr(0, pos), " \t");
|
||||
string = Trim(string.substr(pos, line.length() - pos), " \t");
|
||||
}
|
||||
else if (macro == "COMBO")
|
||||
{
|
||||
string = Trim(string, " \t");
|
||||
|
||||
if (string.at(0) != ',')
|
||||
return;
|
||||
string = string.substr(1, line.length() - 1);
|
||||
|
||||
string = Trim(string, " \t");
|
||||
|
||||
if (string.at(0) != '"')
|
||||
return;
|
||||
|
||||
string = string.substr(1, line.length() - 1);
|
||||
|
||||
int pos = string.find('"');
|
||||
if (pos == -1)
|
||||
return;
|
||||
|
||||
options = Trim(string.substr(0, pos), " \t");
|
||||
++pos;
|
||||
string = Trim(string.substr(pos, line.length() - pos), " \t");
|
||||
}
|
||||
|
||||
if (string.at(0) != ',')
|
||||
return;
|
||||
|
||||
string = Trim(string.substr(1, line.length() - 1), " \t");
|
||||
int pos = string.find(")");
|
||||
if (pos == -1)
|
||||
return;
|
||||
|
||||
name = Trim(string.substr(0, pos), " \t");
|
||||
string = Trim(string.substr(pos, line.length() - pos), " \t");
|
||||
|
||||
if (string.at(0) != ')')
|
||||
return;
|
||||
|
||||
string = Trim(string.substr(1, line.length() - 1), " \t");
|
||||
|
||||
if (string.at(0) != '=')
|
||||
return;
|
||||
|
||||
string = Trim(string.substr(1, line.length() - 1), " \t");
|
||||
|
||||
pos = string.find(';');
|
||||
if (pos == -1)
|
||||
return;
|
||||
|
||||
value = Trim(string.substr(0, pos), " \t");
|
||||
|
||||
#ifdef FILEMON_ACTIVE
|
||||
if (g_Variables.find(name) != g_Variables.end())
|
||||
{
|
||||
if (type == "bool")
|
||||
{
|
||||
*((bool*)g_Variables[name]) = (value == "true");
|
||||
}
|
||||
else if (type == "int")
|
||||
{
|
||||
sscanf_s(value.c_str(), "%d", (int*)g_Variables[name]);
|
||||
}
|
||||
else if (type == "float")
|
||||
{
|
||||
sscanf_s(value.c_str(), "%f", (float*)g_Variables[name]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (macro == "ANY")
|
||||
{
|
||||
g_VariableParams[name] = new AnyParam();
|
||||
}
|
||||
else if (macro == "RANGE")
|
||||
{
|
||||
g_VariableParams[name] = new RangeParam(from, to);
|
||||
}
|
||||
else if (macro == "COMBO")
|
||||
{
|
||||
g_VariableParams[name] = new ComboParam(options);
|
||||
}
|
||||
|
||||
g_VariableTypes[name] = type;
|
||||
g_VariableDefaultValues[name] = value;
|
||||
g_LineNumber[name] = lineNumber;
|
||||
}
|
||||
|
||||
|
||||
void ParseFile(const std::string& filename)
|
||||
{
|
||||
char* content = TextFileRead(filename);
|
||||
char* contentPtr = content;
|
||||
char line[512];
|
||||
int lineNumber = 1;
|
||||
while (contentPtr[0] != 0)
|
||||
{
|
||||
int i = 0;
|
||||
memset(line, 0, 512 * sizeof(char));
|
||||
while (contentPtr[0] != '\n' && contentPtr[0] != '\r' && contentPtr[0] != 0)
|
||||
{
|
||||
line[i++] = *contentPtr++;
|
||||
}
|
||||
ParseLine(line, lineNumber);
|
||||
++lineNumber;
|
||||
while (contentPtr[0] == '\n' || contentPtr[0] == '\r')
|
||||
{
|
||||
++contentPtr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ParseDir(const std::string& dir)
|
||||
{
|
||||
for (std::map<std::string, AnyParam*>::iterator iter = g_VariableParams.begin(); iter != g_VariableParams.end(); ++iter)
|
||||
delete iter->second;
|
||||
g_VariableParams.clear();
|
||||
g_VariableTypes.clear();
|
||||
g_FilesToMonitor.clear();
|
||||
g_FileChangedDate.clear();
|
||||
|
||||
// Create "$(Path)\*.txt" string
|
||||
_finddata_t fdata;
|
||||
std::string searchPath = dir;
|
||||
if (searchPath.at(searchPath.length() - 1) != '\\')
|
||||
searchPath += '\\';
|
||||
|
||||
std::string filesPath = searchPath;
|
||||
searchPath += "*.txt";
|
||||
|
||||
long hfile = _findfirst(searchPath.c_str(), &fdata);
|
||||
if (hfile == -1)
|
||||
{
|
||||
std::cout << "filemon: Didn't find any *.txt files in directory, exiting." << std::endl;
|
||||
return 3;
|
||||
}
|
||||
|
||||
std::vector<std::string> files;
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
std::string fileName = fdata.name;
|
||||
files.push_back(fileName);
|
||||
g_FileChangedDate[i] = fdata.time_write;
|
||||
g_FilesToMonitor[i] = filesPath + fileName;
|
||||
ParseFile(g_FilesToMonitor[i]);
|
||||
++i;
|
||||
} while (_findnext(hfile, &fdata) == 0);
|
||||
_findclose(hfile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
unsigned long __stdcall MonitorFile(void* args)
|
||||
{
|
||||
int fileId = (int)args;
|
||||
while (true)
|
||||
{
|
||||
_finddata_t fdata;
|
||||
long hfile = _findfirst(g_FilesToMonitor[fileId].c_str(), &fdata);
|
||||
if (hfile != -1)
|
||||
{
|
||||
if (fdata.time_write != g_FileChangedDate[fileId])
|
||||
{
|
||||
g_FileChangedDate[fileId] = fdata.time_write;
|
||||
::Sleep(200);
|
||||
ParseFile(g_FilesToMonitor[fileId]);
|
||||
}
|
||||
_findclose(hfile);
|
||||
}
|
||||
::Sleep(200);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
32
evoke-64k/trunk/filemon/filemon/filemon.g.cpp
Normal file
32
evoke-64k/trunk/filemon/filemon/filemon.g.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
// NOTE: This is an autogenerated file, don't bother editing...
|
||||
#include "filemon.h"
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef FILEMON_ACTIVE
|
||||
|
||||
std::map<std::string, std::string> g_VariableTypes;
|
||||
std::map<std::string, std::string> g_VariableDefaultValues;
|
||||
std::map<int, std::string> g_FilesToMonitor;
|
||||
std::map<std::string, void*> g_Variables;
|
||||
|
||||
float g_Alpha = 0.0f;
|
||||
int g_DemoMode = 2;
|
||||
float g_DemoTime = 10.0f;
|
||||
bool g_Doof = false;
|
||||
|
||||
void InitFileMon()
|
||||
{
|
||||
g_Variables["g_Alpha"] = &g_Alpha;
|
||||
g_Variables["g_DemoMode"] = &g_DemoMode;
|
||||
g_Variables["g_DemoTime"] = &g_DemoTime;
|
||||
g_Variables["g_Doof"] = &g_Doof;
|
||||
|
||||
for (unsigned int i = 0; i < g_FilesToMonitor.size(); ++i)
|
||||
{
|
||||
ParseFile(g_FilesToMonitor[i]);
|
||||
::CreateThread(NULL, NULL, MonitorFile, (void*)(int)i, NULL, NULL);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void InitFileMon() {}
|
||||
#endif
|
||||
25
evoke-64k/trunk/filemon/filemon/filemon.h
Normal file
25
evoke-64k/trunk/filemon/filemon/filemon.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
|
||||
#if defined(FILEMON_ACTIVE) || !defined(TWEAKABLES_INSTANCE)
|
||||
#define ANY(type, name) extern type name; type g_FileMonDummy_##name
|
||||
#define RANGE(type, from, to, name) extern type name; type g_FileMonDummy_##name
|
||||
#define COMBO(type, options, name) extern type name; type g_FileMonDummy_##name
|
||||
#else
|
||||
#define ANY(type, name) type name
|
||||
#define RANGE(type, from, to, name) type name
|
||||
#define COMBO(type, options, name) type name
|
||||
#endif
|
||||
|
||||
extern std::map<std::string, std::string> g_VariableDefaultValues;
|
||||
extern std::map<std::string, std::string> g_VariableTypes;
|
||||
extern std::map<int, std::string> g_FilesToMonitor;
|
||||
extern std::map<std::string, void*> g_Variables;
|
||||
|
||||
unsigned long __stdcall MonitorFile(void* args);
|
||||
void InitFileMon();
|
||||
int ParseDir(const std::string& dir);
|
||||
void ParseFile(const std::string& file);
|
||||
213
evoke-64k/trunk/filemon/filemon/filemon.vcproj
Normal file
213
evoke-64k/trunk/filemon/filemon/filemon.vcproj
Normal file
@@ -0,0 +1,213 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="filemon"
|
||||
ProjectGUID="{70D5E87D-2967-4355-8D64-AD7AA82A149C}"
|
||||
RootNamespace="filemon"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
Description="Generating filemon.g.cpp"
|
||||
CommandLine=""$(SolutionDir)Release\$(TargetFileName)" $(ProjectDir) "$(ProjectDir)filemon.g.cpp""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;FILEMON_ACTIVE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shlwapi.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shlwapi.lib"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\compiler.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\filemon.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\filemon.g.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\filemon.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\test.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioUserFile
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
ShowAllFiles="false"
|
||||
>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments="$(ProjectDir) "$(ProjectDir)filemon.g.cpp""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor="0"
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<DebugSettings
|
||||
Command="$(TargetPath)"
|
||||
WorkingDirectory=""
|
||||
CommandArguments=""
|
||||
Attach="false"
|
||||
DebuggerType="3"
|
||||
Remote="1"
|
||||
RemoteMachine="SHAIKUR"
|
||||
RemoteCommand=""
|
||||
HttpUrl=""
|
||||
PDBPath=""
|
||||
SQLDebugging=""
|
||||
Environment=""
|
||||
EnvironmentMerge="true"
|
||||
DebuggerFlavor=""
|
||||
MPIRunCommand=""
|
||||
MPIRunArguments=""
|
||||
MPIRunWorkingDirectory=""
|
||||
ApplicationCommand=""
|
||||
ApplicationArguments=""
|
||||
ShimCommand=""
|
||||
MPIAcceptMode=""
|
||||
MPIAcceptFilter=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
</VisualStudioUserFile>
|
||||
7
evoke-64k/trunk/filemon/filemon/test.txt
Normal file
7
evoke-64k/trunk/filemon/filemon/test.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include "filemon.h"
|
||||
|
||||
ANY(float, g_DemoTime) = 10;
|
||||
RANGE(float, 0, 1, g_Alpha) = 0.83;
|
||||
COMBO(int, "0, 1, 2, 3", g_DemoMode) = 2;
|
||||
ANY(bool, g_Doof) = false;
|
||||
Reference in New Issue
Block a user