Skip to content

Commit 572f4ea

Browse files
authored
Merge pull request #1 from wenwei-dev/tmp
Be able to specify TMP folder path
2 parents 9f8c285 + b3d8d22 commit 572f4ea

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

SRC/dictionarySystem.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ void ShowStats(bool reset)
11091109
void WriteDictDetailsBeforeLayer(int layer)
11101110
{
11111111
char word[MAX_WORD_SIZE];
1112-
sprintf(word,(char*)"TMP/prebuild%d.bin",layer);
1112+
sprintf(word,(char*)"%s/prebuild%d.bin",tmp, layer);
11131113
FILE* out = FopenBinaryWrite(word); // binary file, no BOM
11141114
if (out)
11151115
{
@@ -1137,7 +1137,7 @@ void WriteDictDetailsBeforeLayer(int layer)
11371137
static void ReadDictDetailsBeforeLayer(int layer)
11381138
{
11391139
char word[MAX_WORD_SIZE];
1140-
sprintf(word,(char*)"TMP/prebuild%d.bin",layer);
1140+
sprintf(word,(char*)"%s/prebuild%d.bin",tmp,layer);
11411141
int oldBOM = BOM;
11421142
FILE* in = FopenReadWritten(word); // binary file, no BOM
11431143
if (in)

SRC/mainSystem.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ bool nosuchbotrestart = false; // restart if no such bot
4343
char users[100];
4444
char logs[100];
4545
char topic[100];
46+
char tmp[100];
4647
char buildfiles[100];
4748
char* derivationSentence[MAX_SENTENCE_LENGTH];
4849
int derivationLength;
@@ -583,6 +584,7 @@ static void ProcessArgument(char* arg)
583584
else if (!strnicmp(arg,(char*)"users=",6 )) strcpy(users,arg+6);
584585
else if (!strnicmp(arg,(char*)"logs=",5 )) strcpy(logs,arg+5);
585586
else if (!strnicmp(arg,(char*)"topic=",6 )) strcpy(topic,arg+6);
587+
else if (!strnicmp(arg,(char*)"tmp=",4 )) strcpy(tmp,arg+4);
586588
else if (!strnicmp(arg, (char*)"buildfiles=", 11)) strcpy(buildfiles, arg + 11);
587589
else if (!strnicmp(arg,(char*)"private=",8)) privateParams = arg+8;
588590
else if (!stricmp(arg,(char*)"treetagger")) strcpy(treetaggerParams,"1");
@@ -684,7 +686,6 @@ static void ReadConfig()
684686
unsigned int InitSystem(int argcx, char * argvx[],char* unchangedPath, char* readablePath, char* writeablePath, USERFILESYSTEM* userfiles, DEBUGAPI infn, DEBUGAPI outfn)
685687
{ // this work mostly only happens on first startup, not on a restart
686688
strcpy(hostname,(char*)"local");
687-
MakeDirectory((char*)"TMP");
688689
*sourceInput = 0;
689690
*buildfiles = 0;
690691
*apikey = 0;
@@ -714,6 +715,7 @@ unsigned int InitSystem(int argcx, char * argvx[],char* unchangedPath, char* rea
714715
strcpy(users,(char*)"USERS");
715716
strcpy(logs,(char*)"LOGS");
716717
strcpy(topic,(char*)"TOPIC");
718+
strcpy(tmp,(char*)"TMP");
717719

718720
strcpy(language,(char*)"ENGLISH");
719721

@@ -756,6 +758,7 @@ unsigned int InitSystem(int argcx, char * argvx[],char* unchangedPath, char* rea
756758

757759
ReadConfig();
758760
ProcessArguments(argc,argv);
761+
MakeDirectory(tmp);
759762
if (argumentsSeen) printf("\r\n");
760763
argumentsSeen = false;
761764

SRC/mainSystem.h

+1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ extern bool shortPos;
142142
extern char users[100];
143143
extern char logs[100];
144144
extern char topic[100];
145+
extern char tmp[100];
145146
extern char buildfiles[100];
146147

147148
// pending control

SRC/scriptCompile.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,9 @@ static void WriteKey(char* word)
13221322
{
13231323
if (!compiling || spellCheck != NOTE_KEYWORDS || *word == '_' || *word == '\'' || *word == USERVAR_PREFIX || *word == SYSVAR_PREFIX || *word == '@') return;
13241324
StoreWord(word);
1325-
FILE* out = FopenUTF8WriteAppend((char*)"TMP/keys.txt");
1325+
char file[SMALL_WORD_SIZE];
1326+
sprintf(file,(char*)"%s/keys.txt",tmp);
1327+
FILE* out = FopenUTF8WriteAppend(file);
13261328
if (out)
13271329
{
13281330
DownHierarchy(MakeMeaning(StoreWord(word)),out,0);
@@ -5028,15 +5030,18 @@ static void WriteDictionaryChange(FILE* dictout, unsigned int build)
50285030
{
50295031
// Note that topic labels (topic.name) and pattern words will not get written
50305032
FILE* in = NULL;
5033+
char file[SMALL_WORD_SIZE];
50315034
int layer = 0;
50325035
if ( build == BUILD0)
50335036
{
5034-
in = FopenReadWritten((char*)"TMP/prebuild0.bin");
5037+
sprintf(file,(char*)"%s/prebuild0.bin",tmp);
5038+
in = FopenReadWritten(file);
50355039
layer = 0;
50365040
}
50375041
else if ( build == BUILD1)
50385042
{
5039-
in = FopenReadWritten((char*)"TMP/prebuild1.bin");
5043+
sprintf(file,(char*)"%s/prebuild1.bin",tmp);
5044+
in = FopenReadWritten(file);
50405045
layer = 1;
50415046
}
50425047
if (!in)

SRC/userSystem.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,11 @@ void WriteUserData(time_t curr)
636636
if (filesystemOverride == NORMALFILES && (!server || serverRetryOK) && !documentMode && !callback)
637637
{
638638
char fname[MAX_WORD_SIZE];
639-
sprintf(fname,(char*)"TMP/backup-%s_%s.bin",loginID,computerID);
639+
sprintf(fname,(char*)"%s/backup-%s_%s.bin",tmp,loginID,computerID);
640640
CopyFile2File(fname, name,false); // backup for debugging BUT NOT if callback of some kind...
641641
if (redo) // multilevel backup enabled
642642
{
643-
sprintf(fname,(char*)"TMP/backup%d-%s_%s.bin",volleyCount,loginID,computerID);
643+
sprintf(fname,(char*)"%s/backup%d-%s_%s.bin",tmp,volleyCount,loginID,computerID);
644644
CopyFile2File(fname,userDataBase,false); // backup for debugging BUT NOT if callback of some kind...
645645
}
646646
}
@@ -664,11 +664,11 @@ void WriteUserData(time_t curr)
664664
#ifndef DISCARDTESTING
665665
if (filesystemOverride == NORMALFILES && (!server || serverRetryOK) && !documentMode && !callback)
666666
{
667-
sprintf(name,(char*)"TMP/backup-share-%s_%s.bin",loginID,computerID);
667+
sprintf(name,(char*)"%s/backup-share-%s_%s.bin",tmp,loginID,computerID);
668668
CopyFile2File(name,userDataBase,false); // backup for debugging
669669
if (redo)
670670
{
671-
sprintf(name,(char*)"TMP/backup%d-share-%s_%s.bin",volleyCount,loginID,computerID);
671+
sprintf(name,(char*)"%s/backup%d-share-%s_%s.bin",tmp,volleyCount,loginID,computerID);
672672
CopyFile2File(name,userDataBase,false); // backup for debugging BUT NOT if callback of some kind...
673673
}
674674
}

0 commit comments

Comments
 (0)