These are the
jgc_file files in Jegas Game Classes. There are utilitiy functions in there JUST for this purpose - interrogating your hardware etc via checklist:
jgc_file.h
/*============================================================================
| _________ _______ _______ ______ _______ Jegas, LLC |
| /___ ___// _____/ / _____/ / __ / / _____/ JasonPSage@jegas.com |
| / / / /__ / / ___ / /_/ / / /____ |
| / / / ____/ / / / / / __ / /____ / |
|____/ / / /___ / /__/ / / / / / _____/ / |
/_____/ /______/ /______/ /_/ /_/ /______/ |
| Under the Hood |
==============================================================================
Copyright(c)2009 Jegas, LLC
============================================================================*/
#pragma once
#include <DarkGDK.H>
#include "jfc_date.h"
#include "jfc_string.h"
#include "jfc_dl.h"
//SAMPLES:
/*
JGC::File->SaveFontChecklist("CheckListFonts.txt");
JGC::File->SaveControlDevicesChecklist("CheckListControlDevices.txt");
JGC::File->SaveDisplayModesChecklist("CheckListDisplayModes.txt");
JGC::File->SaveDrivesCheckList("CheckListDrives.txt");
JGC::File->SaveGraphicsCardsChecklist("CheckListGraphicsCards.txt");
JGC::File->SaveNetConnectionsChecklist("CheckListNetConnections.txt");
JGC::File->SaveNetPlayersChecklist("CheckListNetPlayers.txt");
JGC::File->SaveNetSessionsChecklist("ChecklistNetSessions.txt");
JGC::File->SaveFilesChecklist("ChecklistFiles.txt");
*/
//============================================================================
class JGC_FILE{
//============================================================================
private:
JFC_STRING *pvt_DirAtStartUp;
JFC_STRING *pvt_DirCurrent;
JFC_STRING *pvt_LogFilename;
int pvt_LogFileHandle;
bool pvt_LogfileEnabled;
int pvt_LogFilePriorityMax;
public:
JGC_FILE(
bool p_Log_Enabled,
char *p_szLog_Filename,
int p_Log_PriorityMax
);
~JGC_FILE();
char *Dir_AtStartUp_Get(void);
char *Dir_Get(void);
void Dir_Set(char *p_char);
// returns true if file NOT there before it returns!
// (Regardless if it deleted it or file didn't exist.)
bool DeleteFile(char *p_char);
bool Exist(char* p_szFilename);
int FreeFile(void);
void SaveFontChecklist(char *p_szFilename);
void SaveDisplayModesChecklist(char *p_szFilename);
void SaveControlDevicesChecklist(char *p_szFilename);
void SaveDrivesCheckList(char *p_szFilename);
void SaveFilesChecklist(char *p_szFilename);
void SaveGraphicsCardsChecklist(char *p_szFilename);
void SaveEffectValuesCheckList(char *p_szFilename, int p_EffectID);
void SaveEffectErrorsCheckList(char *p_szFilename, int p_EffectID=0);
void SaveObjectLimbsCheckList(char *p_szFilename, int p_ObjectID);
void SaveNetConnectionsChecklist(char *p_szFilename);
void SaveNetSessionsChecklist(char *p_szFilename);
void SaveNetPlayersChecklist(char *p_szFilename);
void WriteJegasLogo(int p_FileHandle,JFC_STRING *Str);
void WriteJegasEof(int p_FileHandle,JFC_STRING *Str);
void WriteJegasSeparator(int p_FileHandle,JFC_STRING *Str);
void Log(
int p_Priority,
char *p_szCode,
char *p_szString
);
};
//============================================================================
//============================================================================
class JGC_DIRITEM :public JFC_DLITEM{
//============================================================================
public:
JFC_STRING *Filename;
bool Directory;
JFC_STRING *FileDateCreationStr;// Date GDK gives a string, I'll go with it ;)
JFC_STRING *FileDateStr;// Date GDK gives a string, I'll go with it ;)
JFC_STRING *FileExt;// Made to allow Sorting by File Ext.
JGC_DIRITEM();
~JGC_DIRITEM();
};
//============================================================================
//============================================================================
class JGC_DIRDL:public JFC_DL{
//---------------------------------------------------------------------
void *pvt_CreateItem(void) override;
// Place to put "generations" of code thats you can add to but inherit the
// previous generation - unlike pvt_createitem which gets overriden entirely
// CALLED AFTER pvt_createItem
void pvt_createtask(void);
// OVERRIDE - DON'T INHERIT!
// Make This DESTROY your ClassItem When p_ptr (pointer to YOUR class) is
// sent.
void pvt_DestroyItem(void * p_Item) override;
// Place to put "generations" of code thats you can add to but inherit the
// previous generation - unlike pvt_destroyitem which gets overriden entirely
// CALLED BEFORE pvt_DestroyItem
void pvt_destroytask(void * p_Item);
public:
JGC_DIRDL();
~JGC_DIRDL();
JFC_STRING *DirName;
JFC_DL *FileExtDL;// If Empty, same as SHOW ALL FILES. (Use Str field
// in JFC_DLITEM->Str (JFC_STRING class))for this.
//methods
void LoadDir(bool p_SortByFileAscending=true);
void SortByFilename(bool p_Ascending);
void SortByDateCreated(bool p_Ascending);
void SortByDateModified(bool p_Ascending);
void SortByExt(bool p_Ascending);
void SortByDir(bool p_Ascending);// just put directories last (descending does typical)
// this sorts by if file or directory, not the directory name
};
//============================================================================
jgc_file.cpp
/*============================================================================
| _________ _______ _______ ______ _______ Jegas, LLC |
| /___ ___// _____/ / _____/ / __ / / _____/ JasonPSage@jegas.com |
| / / / /__ / / ___ / /_/ / / /____ |
| / / / ____/ / / / / / __ / /____ / |
|____/ / / /___ / /__/ / / / / / _____/ / |
/_____/ /______/ /______/ /_/ /_/ /______/ |
| Under the Hood |
==============================================================================
Copyright(c)2009 Jegas, LLC
============================================================================*/
#include "jgc_file.h"
#include "jgc_common.h"
//============================================================================
// begin JGC_FILE
//============================================================================
//----------------------------------------------------------------------------
JGC_FILE::JGC_FILE(
bool p_Log_Enabled,
char *p_szLog_Filename,
int p_Log_PriorityMax
){
//----------------------------------------------------------------------------
this->pvt_DirAtStartUp=new JFC_STRING();
this->pvt_DirAtStartUp->Set(dbGetDir());
this->pvt_DirCurrent=new JFC_STRING();
this->pvt_DirCurrent->Set(this->pvt_DirAtStartUp->Get());
this->pvt_LogFileHandle=0;
this->pvt_LogFilename=new JFC_STRING();
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
JGC_FILE::~JGC_FILE(){
//----------------------------------------------------------------------------
SAFE_DELETE(this->pvt_DirAtStartUp);
SAFE_DELETE(this->pvt_DirCurrent);
SAFE_DELETE(this->pvt_LogFilename);
if(this->pvt_LogFileHandle!=0){
JFC_STRING *s=new JFC_STRING();
this->WriteJegasEof(this->pvt_LogFileHandle,s);
SAFE_DELETE(s);
dbCloseFile(this->pvt_LogFileHandle);
};
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
char *JGC_FILE::Dir_AtStartUp_Get(void){
//----------------------------------------------------------------------------
return this->pvt_DirAtStartUp->Get();
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
char *JGC_FILE::Dir_Get(void){
//----------------------------------------------------------------------------
this->pvt_DirCurrent->Set(dbGetDir());
return this->pvt_DirCurrent->Get();
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::Dir_Set(char *p_char){
//----------------------------------------------------------------------------
this->pvt_DirCurrent->Set(p_char);
dbSetDir(this->pvt_DirCurrent->Get());
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool JGC_FILE::Exist(char* p_szFilename){
//----------------------------------------------------------------------------
bool bExists = dbFileExist(p_szFilename);
return bExists;// I write it in two lines for debugging purposes.
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::WriteJegasLogo(int p_FileHandle,JFC_STRING *Str){
//----------------------------------------------------------------------------
this->WriteJegasSeparator(p_FileHandle,Str);
Str->Set(";| _________ _______ _______ ______ _______ Jegas, LLC |");dbWriteString(p_FileHandle,Str->s);
Str->Set(";| /___ ___// _____/ / _____/ / __ / / _____/ JasonPSage@jegas.com |");dbWriteString(p_FileHandle,Str->s);
Str->Set(";| / / / /__ / / ___ / /_/ / / /____ |");dbWriteString(p_FileHandle,Str->s);
Str->Set(";| / / / ____/ / / / / / __ / /____ / |");dbWriteString(p_FileHandle,Str->s);
Str->Set(";|____/ / / /___ / /__/ / / / / / _____/ / |");dbWriteString(p_FileHandle,Str->s);
Str->Set(";/_____/ /______/ /______/ /_/ /_/ /______/ |");dbWriteString(p_FileHandle,Str->s);
Str->Set(";| Under the Hood |");dbWriteString(p_FileHandle,Str->s);
this->WriteJegasSeparator(p_FileHandle,Str);
Str->Set("; Copyright(c)2008 Jegas, LLC");dbWriteString(p_FileHandle,Str->s);
this->WriteJegasSeparator(p_FileHandle,Str);
Str->Set(" IF YOU ARE VIEWING THIS FROM INSIDE VISUAL STUDIO NOTE:");dbWriteString(p_FileHandle,Str->s);
Str->Set(" Visual Studio can not successfuly reload files in use by DarkGDK.");dbWriteString(p_FileHandle,Str->s);
Str->Set(" STOP Your debugger, close the 'tab' with this file in it, and reopen manually!");dbWriteString(p_FileHandle,Str->s);
this->WriteJegasSeparator(p_FileHandle,Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::WriteJegasEof(int p_FileHandle,JFC_STRING*Str){
//----------------------------------------------------------------------------
this->WriteJegasSeparator(p_FileHandle,Str);
Str->Set("; EOF");dbWriteString(p_FileHandle,Str->s);
this->WriteJegasSeparator(p_FileHandle,Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::WriteJegasSeparator(int p_FileHandle, JFC_STRING*Str){
//----------------------------------------------------------------------------
Str->Set(";==============================================================================");
dbWriteString(p_FileHandle,Str->s);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveFontChecklist(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistForFonts();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Font Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
//sprintf(JFC::CHAR1K,"FontChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("FontName=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
//sprintf(JFC::CHAR1K,"FontChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
//sprintf(JFC::CHAR1K,"FontChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
//sprintf(JFC::CHAR1K,"FontChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
//sprintf(JFC::CHAR1K,"FontChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
//Str->Clear();dbWriteString(1,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveDisplayModesChecklist(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistForDisplayModes();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Display Modes Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(1,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveControlDevicesChecklist(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistControlDevices();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Control Devices Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveDrivesCheckList(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformCheckListForDrives();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Drives Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveFilesChecklist(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformCheckListForFiles();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Files Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveGraphicsCardsChecklist(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistForGraphicsCards();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Graphics Cards Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveEffectValuesCheckList(char *p_szFilename, int p_EffectID){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistForEffectValues(p_EffectID);
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Effect Values Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveEffectErrorsCheckList(char *p_szFilename, int p_EffectID){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
if(p_EffectID==0){
dbPerformChecklistForEffectErrors();
}else{
dbPerformChecklistForEffectErrors(p_EffectID);
};
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(1,Str);
Str->Set("; Effect Errors Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(1,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveObjectLimbsCheckList(char *p_szFilename, int p_ObjectID){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistForObjectLimbs(p_ObjectID);
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Object Limbs Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveNetConnectionsChecklist(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistForNetConnections();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Net Connections Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveNetSessionsChecklist(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistForNetSessions();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Net Sessions Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::SaveNetPlayersChecklist(char *p_szFilename){
//----------------------------------------------------------------------------
int fh=this->FreeFile();
dbPerformChecklistForNetPlayers();
int i=0;
int q = dbChecklistQuantity();
JFC_STRING *Str = new JFC_STRING();
if(this->DeleteFile(p_szFilename)){
dbOpenToWrite(fh,p_szFilename);
JGC::File->WriteJegasLogo(fh,Str);
//Str->Set("CURRENTDIR: ");Str->ConCat(File->Dir_Get());dbWriteString(1,Str->s);
Str->Set(";FILENAME: ");Str->ConCat(p_szFilename);dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
Str->Set("; Net Players Checklist");dbWriteString(fh,Str->s);
JGC::File->WriteJegasSeparator(fh,Str);
sprintf(JFC::CHAR1K,"; Items Returned In Checklist: %i",q);Str->Set(JFC::CHAR1K); dbWriteString(fh,Str->s);
for(i=0;i<q;i++){
sprintf(JFC::CHAR1K,"ChecklistPosition=%i",i+1);Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Set("ChecklistString=");Str->ConCat(dbChecklistString(i+1));dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueA=%i",dbChecklistValueA(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueB=%i",dbChecklistValueB(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueC=%i",dbChecklistValueC(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
sprintf(JFC::CHAR1K,"ChecklistValueD=%i",dbChecklistValueD(i+1));Str->Set(JFC::CHAR1K);dbWriteString(fh,Str->s);
Str->Clear();dbWriteString(fh,Str->s);
};
JGC::File->WriteJegasEof(fh,Str);
dbCloseFile(fh);
};
dbEmptyChecklist();
SAFE_DELETE(Str);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
bool JGC_FILE::DeleteFile(char *p_char){
//----------------------------------------------------------------------------
if(this->Exist(p_char)){
dbDeleteFile(p_char);
};
return (!this->Exist(p_char));
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
int JGC_FILE::FreeFile(void){
//----------------------------------------------------------------------------
int r=0; int i=1;
do{
int fh=dbFileOpen(i);
if(fh!=1){
r=i;
};
i++;
}while(r==0 && i<=32);
return r;
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_FILE::Log(
int p_Priority,
char *p_szCode,
char *p_szString
){
//----------------------------------------------------------------------------
if(this->pvt_LogfileEnabled){
if(p_Priority<=this->pvt_LogFilePriorityMax){
if(this->pvt_LogFileHandle==0){// First Call... Must create/open the file
if(this->Exist(this->pvt_LogFilename->s)){
dbDeleteFile(this->pvt_LogFilename->s);
};
this->pvt_LogFileHandle=this->FreeFile();
dbOpenToWrite(this->pvt_LogFileHandle,this->pvt_LogFilename->s);
JFC_STRING *s=new JFC_STRING();
this->WriteJegasLogo(this->pvt_LogFileHandle, s);
s->Set(" Jegas Dark GDK Log File.");
dbWriteString(this->pvt_LogFileHandle,s->s);
this->WriteJegasSeparator(this->pvt_LogFileHandle,s);
s->Set("YYYYMMDDHHmm, Priority, LOGENTRYCODE, \"Log Entry Text\"");
dbWriteString(this->pvt_LogFileHandle,s->s);
this->WriteJegasSeparator(this->pvt_LogFileHandle,s);
};
JFC_STRING *f = new JFC_STRING();
JFC_STRING *s = new JFC_STRING();
s->Set(dbGetDate());//MM/DD/YY
char d[9];
d[0]='2';
d[1]='0';
d[2]=s->s[6];
d[3]=s->s[7];
d[4]=s->s[0];
d[5]=s->s[1];
d[6]=s->s[3];
d[7]=s->s[4];
d[8]=(char)0;
//char t[7]; LOSE the seconds
char t[5];
s->Set(dbGetTime());//HH:MM:SS
t[0]=s->s[0];
t[1]=s->s[1];
t[2]=s->s[3];
t[3]=s->s[4];
t[4]=(char)0;
//t[4]=s->s[6];
//t[5]=s->s[7];
//t[6]=(char)0;
s->Set(d);
s->ConCat(t);
s->ConCat(", ");
sprintf(JFC::CHAR1K ,"%i",p_Priority);
s->ConCat(JFC::CHAR1K);
s->ConCat(", \"");
s->ConCat(p_szCode);
s->ConCat("\", \"");
s->ConCat(p_szString);
s->ConCat("\"");
dbWriteString(this->pvt_LogFileHandle,s->s);
SAFE_DELETE(s);
SAFE_DELETE(f);
};
};
};
//----------------------------------------------------------------------------
//============================================================================
// end JGC_FILE
//============================================================================
//============================================================================
// begin JGC_DIRITEM
//============================================================================
//----------------------------------------------------------------------------
JGC_DIRITEM::JGC_DIRITEM(){
//----------------------------------------------------------------------------
Filename = new JFC_STRING();
Directory=false;
FileDateCreationStr=new JFC_STRING();
FileDateStr=new JFC_STRING();
FileExt=new JFC_STRING();
this->ClassName->Set("JGC_DIRITEM");
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
JGC_DIRITEM::~JGC_DIRITEM(){
//----------------------------------------------------------------------------
SAFE_DELETE(Filename);
SAFE_DELETE(FileDateStr);
SAFE_DELETE(FileExt);
};
//----------------------------------------------------------------------------
//============================================================================
// end JGC_DIRITEM
//============================================================================
//============================================================================
// begin JGC_DIRDL
//============================================================================
//----------------------------------------------------------------------------
JGC_DIRDL::JGC_DIRDL(){
//----------------------------------------------------------------------------
DirName=new JFC_STRING();
FileExtDL=new JFC_DL();
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
JGC_DIRDL::~JGC_DIRDL(){
//----------------------------------------------------------------------------
SAFE_DELETE(DirName);
SAFE_DELETE(FileExtDL);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void *JGC_DIRDL::pvt_CreateItem(void){
//----------------------------------------------------------------------------
return new JGC_DIRITEM();
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::pvt_createtask(void){
//----------------------------------------------------------------------------
// nothing to do
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::pvt_DestroyItem(void * p_Item){
//----------------------------------------------------------------------------
delete (JGC_DIRITEM*)p_Item;p_Item=NULL;
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::pvt_destroytask(void * p_Item){
//----------------------------------------------------------------------------
// nothing to do here
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::LoadDir(bool p_SortByFileAscending){
//----------------------------------------------------------------------------
JFC_STRING *s=new JFC_STRING();
JFC_STRING *s2=new JFC_STRING();
int Type=0;
JFC_STRING *CurDir = new JFC_STRING(JGC::File->Dir_Get());
JGC::File->Dir_Set(this->DirName->s);
dbFindFirst();
bool Done=false;
bool Keep=true;
bool FilterActive=this->FileExtDL->MoveFirst();
do{
Type=dbGetFileType();
if(Type!=-1){
this->AppendItem();
JGC_DIRITEM *Dir=(JGC_DIRITEM*)this->Item;
Dir->Directory = Type!=0;
Dir->FileDateCreationStr->Set(JFC::DateGDKConv(dbGetFileCreation()));
Dir->FileDateStr->Set(JFC::DateGDKConv(dbGetFileDate()));
Dir->Filename->Set(dbGetFileName());
if(!Dir->Directory){
s->Reverse(Dir->Filename->s);
int i=s->IndexOf(".",0,false);
if(i>-1){
s2->Left(s->s,i);
if(FilterActive){
Keep=this->FileExtDL->FoundString(s2->s,false,offsetof(JFC_DLITEM,Str),true,false,true);
};
Dir->FileExt->Set(s2->s);
}else{
// No Extension
if(FilterActive){
Keep=this->FileExtDL->FoundString("",false,offsetof(JFC_DLITEM,Str),true,false,true);
};
Dir->FileExt->Set("");// not necessary but...
};
Dir->FileExt->Reverse();
Dir->FileExt->Upper();
if(FilterActive && (!Keep)){
this->DeleteItem();
};
};
dbFindNext();
}else{
Done=true;
};
}while(!Done);
this->SortByFilename(p_SortByFileAscending);
this->SortByDir(!p_SortByFileAscending);
SAFE_DELETE(s);
SAFE_DELETE(s2);
JGC::File->Dir_Set(CurDir->s);
SAFE_DELETE(CurDir);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::SortByFilename(bool p_Ascending){
//----------------------------------------------------------------------------
this->SortString(false,offsetof(JGC_DIRITEM,Filename),p_Ascending,false,true);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::SortByDateCreated(bool p_Ascending){
//----------------------------------------------------------------------------
this->SortString(false,offsetof(JGC_DIRITEM,FileDateCreationStr),p_Ascending,false,true);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::SortByDateModified(bool p_Ascending){
//----------------------------------------------------------------------------
this->SortString(false,offsetof(JGC_DIRITEM,FileDateStr),p_Ascending,false,true);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::SortByExt(bool p_Ascending){
//----------------------------------------------------------------------------
this->SortString(false,offsetof(JGC_DIRITEM,FileExt),p_Ascending,false,true);
};
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
void JGC_DIRDL::SortByDir(bool p_Ascending){
//----------------------------------------------------------------------------
this->SortBinary(sizeof(bool),offsetof(JGC_DIRITEM,Directory),p_Ascending,false);
};
//----------------------------------------------------------------------------
//============================================================================
// end JGC_DIRDL
//============================================================================
I hope these shed some light on matters for ya
--Jason