Skip to content

Commit 19d49bc

Browse files
refactor: constant file names
Also move the constant out the main.pas to lower unit that can also be included by unit test.
1 parent e6e4b86 commit 19d49bc

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

source/code/main.pas

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -197,28 +197,16 @@ implementation
197197
'udp://tracker.leechers-paradise.org:6969/announce',
198198
'udp://tracker.opentrackr.org:1337/announce'
199199
);
200+
200201
//program name and version (http://semver.org/)
201202
FORM_CAPTION = 'Bittorrent tracker editor (1.33.0.beta.1)';
203+
202204
TORRENT_FILES_CONTENTS_FORM_CAPTION =
203205
'Show all the files inside the torrents. (Use right mouse for popup menu.)';
204206

205207
GROUPBOX_PRESENT_TRACKERS_CAPTION =
206208
'Present trackers in all torrent files. Select the one that you want to keep. And added to all torrent files.';
207209

208-
209-
//'add trackers' text file must be place in the same directory as the program.
210-
ADD_TRACKERS_FILE_NAME = 'add_trackers.txt';
211-
212-
//'remove trackers' text file must be place in the same directory as the program.
213-
REMOVE_TRACKERS_FILE_NAME = 'remove_trackers.txt';
214-
215-
//'export trackers' text file wil be created in the same directory as the program.
216-
EXPORT_TRACKERS_FILE_NAME = 'export_trackers.txt';
217-
218-
//'log' text file will be saved in the same directory as the program
219-
// only in the console mode.
220-
LOG_FILE_NAME = 'console_log.txt';
221-
222210
{$R *.lfm}
223211

224212
{ TFormTrackerModify }
@@ -775,7 +763,7 @@ procedure TFormTrackerModify.SaveTrackerFinalListToFile;
775763
begin
776764
//Create the tracker text file. The old one will be overwritten
777765
AssignFile(FTrackerFile, ExtractFilePath(Application.ExeName) +
778-
EXPORT_TRACKERS_FILE_NAME);
766+
FILE_NAME_EXPORT_TRACKERS);
779767
ReWrite(FTrackerFile);
780768
for TrackerStr in FTrackerList.TrackerFinalList do
781769
begin
@@ -1126,7 +1114,7 @@ procedure TFormTrackerModify.LoadTrackersTextFileAddTrackers;
11261114

11271115
//if no file is found the use the default tracker list.
11281116
if not ReadAddTrackerFileFromUser(ExtractFilePath(Application.ExeName) +
1129-
ADD_TRACKERS_FILE_NAME) then
1117+
FILE_NAME_ADD_TRACKERS) then
11301118
begin
11311119
MemoNewTrackers.Lines.BeginUpdate;
11321120
for i := low(RECOMENDED_TRACKERS) to high(RECOMENDED_TRACKERS) do
@@ -1147,7 +1135,7 @@ procedure TFormTrackerModify.LoadTrackersTextFileRemoveTrackers;
11471135
var
11481136
filename: UTF8String;
11491137
begin
1150-
filename := ExtractFilePath(Application.ExeName) + REMOVE_TRACKERS_FILE_NAME;
1138+
filename := ExtractFilePath(Application.ExeName) + FILE_NAME_REMOVE_TRACKERS;
11511139
try
11521140
FFilePresentBanByUserList := FileExistsUTF8(fileName);
11531141
if FFilePresentBanByUserList then

source/code/torrent_miscellaneous.pas

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,21 @@ function TrackerURLWithAnnounce(const TrackerURL: UTF8String): boolean;
124124
);
125125

126126

127+
//'add trackers' text file must be place in the same directory as the program.
128+
FILE_NAME_ADD_TRACKERS: string = 'add_trackers.txt';
129+
130+
//'remove trackers' text file must be place in the same directory as the program.
131+
FILE_NAME_REMOVE_TRACKERS: string = 'remove_trackers.txt';
132+
133+
//'export trackers' text file wil be created in the same directory as the program.
134+
FILE_NAME_EXPORT_TRACKERS: string = 'export_trackers.txt';
135+
136+
//'log' text file will be saved in the same directory as the program
137+
// only in the console mode.
138+
FILE_NAME_CONSOLE_LOG: string = 'console_log.txt';
139+
140+
CONSOLE_SUCCESS_STATUS: string = 'OK';
141+
127142
implementation
128143

129144
uses LazUTF8, LazFileUtils;

0 commit comments

Comments
 (0)