Skip to content

Commit

Permalink
Updated plugin, v1.1
Browse files Browse the repository at this point in the history
Fixed some internal bugs and introduced a log system.
  • Loading branch information
xrebelox committed Mar 14, 2017
1 parent 75e6340 commit de2470b
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 18 deletions.
Binary file modified .vs/chatlogarchiver/v14/.suo
Binary file not shown.
Binary file modified Release/chatlogarchiver.iobj
Binary file not shown.
Binary file modified Release/chatlogarchiver.ipdb
Binary file not shown.
Binary file modified Release/chatlogarchiver.pdb
Binary file not shown.
Binary file removed chatlogarchiver.VC.opendb
Binary file not shown.
Binary file modified chatlogarchiver.sdf
Binary file not shown.
8 changes: 4 additions & 4 deletions chatlogarchiver/Release/chatlogarchiver.log
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
 main.cpp
Generating code
3 of 226 functions ( 1.3%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation
15 functions had inline decision re-evaluated but remain unchanged
93 of 273 functions (34.1%) were compiled, the rest were copied from previous compilation.
47 functions were new in current compilation
50 functions had inline decision re-evaluated but remain unchanged
Finished generating code
chatlogarchiver.vcxproj -> C:\Users\RebeloX\Desktop\gtan\chatlogarchiver\Release\chatlogarchiver.dll
chatlogarchiver.vcxproj -> C:\Users\RebeloX\Documents\GitHub\chatlogarchiver\Release\chatlogarchiver.dll
Binary file modified chatlogarchiver/Release/chatlogarchiver.tlog/CL.command.1.tlog
Binary file not shown.
Binary file modified chatlogarchiver/Release/chatlogarchiver.tlog/CL.read.1.tlog
Binary file not shown.
Binary file modified chatlogarchiver/Release/chatlogarchiver.tlog/CL.write.1.tlog
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
Release|Win32|C:\Users\RebeloX\Desktop\gtan\chatlogarchiver\|
Release|Win32|C:\Users\RebeloX\Documents\GitHub\chatlogarchiver\|
Binary file modified chatlogarchiver/Release/chatlogarchiver.tlog/link.command.1.tlog
Binary file not shown.
Binary file modified chatlogarchiver/Release/chatlogarchiver.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified chatlogarchiver/Release/chatlogarchiver.tlog/link.write.1.tlog
Binary file not shown.
Binary file modified chatlogarchiver/Release/vc140.pdb
Binary file not shown.
3 changes: 3 additions & 0 deletions chatlogarchiver/chatlogarchiver.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,15 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CHATLOGARCHIVER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\RebeloX\Documents\GitHub\chatlogarchiver\chatlogarchiver\include\C++;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Users\RebeloX\Documents\GitHub\chatlogarchiver\chatlogarchiver\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand Down
53 changes: 40 additions & 13 deletions chatlogarchiver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
#include <string>
#include <time.h>


#pragma warning(disable:4996) //disables shitty warnings about time and shit who cares?

std::wstring path; //define strange shit to be used between the functions
void DebugLog(std::wstring content);
void StartPlugin();
void EndPlugin();
HMODULE processModule;
Expand Down Expand Up @@ -51,15 +53,20 @@ BOOL DirectoryExists(LPCTSTR szPath)
void StartPlugin()
{
//read directory

DebugLog(L"Starting plugin and verifying configuration file;");
if (std::ifstream("chatlogarchiver.ini"))
{
DebugLog(L"Configuration file found, reading settings;");
//file exists, proceed to extract the path.
WCHAR output[MAX_PATH];
GetPrivateProfileString(L"settings", L"path", NULL, output, MAX_PATH, L".\\chatlogarchiver.ini");

DebugLog(L"Checking directory;");
//check if the path is valid, by checking if the directory exists.
if (DirectoryExists(output))
{
DebugLog(L"Directory found;");
path = output; //path receives the value from the output.

//create a variable to check if the archive folder exists.
Expand All @@ -69,38 +76,58 @@ void StartPlugin()
//check if the archive folder does not exists
if (!DirectoryExists(folder.c_str()))
{
DebugLog(L"Creating archive folder;");
//makes the archive folder.
CreateDirectory(folder.c_str(), NULL);
}

}
else {
//if directory isn't valid we must kill the process.
DebugLog(L"Directory is not valid, check the configuration file;");
FreeLibrary(processModule);
Beep(750, 300);
}
}
else {
//kills the DLL
DebugLog(L"Configuration file not found, please create a \"chatlogarchiver.ini\" file;");
FreeLibrary(processModule);
Beep(750, 300);
}

}

void EndPlugin()
std::wstring getCurrentTime()
{
//get the current time
time_t rawTime;
tm * timeInfo;
time_t rawTime; tm * timeInfo;

time(&rawTime); timeInfo = localtime(&rawTime);

char output[100];
size_t l = strftime(output, sizeof(output), "%Y-%m-%d - %Hh%Mm%Ss", timeInfo);

time(&rawTime);
timeInfo = localtime(&rawTime);
//end
return std::wstring(output, output + strlen(output));
}

//convert the current time to so it can be used as a file name.
char filename[100];
size_t l = strftime(filename, sizeof(filename), "%Y-%m-%d - %Hh%Mm%Ss.txt", timeInfo);
std::wstring file(filename, filename + strlen(filename));
void EndPlugin()
{
DebugLog(L"Closing the plugin;");

//joins all together to create the destination path and source path.
std::wstring destination(path + L"\\archive\\" + file);
std::wstring destination(path + L"\\archive\\" + getCurrentTime() + L".txt");
std::wstring source(path + L"\\chatlog.txt");


DebugLog(L"Copying file to destination folder;");
//finishes up by copying the file to destination path.
CopyFile(source.c_str(), destination.c_str(), FALSE);
}

void DebugLog(std::wstring content)
{
std::wofstream logfile;
logfile.open("chatlogarchiver.log", std::ios::app);
logfile << L"[" + getCurrentTime() + L"] " + content << std::endl;
logfile.close();
}

0 comments on commit de2470b

Please sign in to comment.