Skip to content
Browse files

Migrate files from old default snippets directory. Closes #159

  • Loading branch information
ansgarbecker committed Feb 25, 2018
1 parent 25717dc commit 424b9f9ab4c620dd6945d69e9652ee828b0b26eb
Showing with 39 additions and 2 deletions.
  1. +10 −1 out/locale/en/LC_MESSAGES/default.po
  2. +29 −1 source/main.pas
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2018-02-03 15:54+0100\n"
"PO-Revision-Date: 2018-02-25 15:32+0100\n"
"Last-Translator: Ansgar Becker <>\n"
"Language-Team: English (\n"
"MIME-Version: 1.0\n"
@@ -6233,3 +6233,12 @@ msgstr "Please update %s through the Microsoft Store."
# Text in parentheses for detected linebreak style in popup text editor
msgid "detected"
msgstr "detected"

msgid "Migrating snippet files to new folder: %s"
msgstr "Migrating snippet files to new folder: %s"

msgid "Successfully moved \"%s\" to \"%s\""
msgstr "Successfully moved \"%s\" to \"%s\""

msgid "Error: Could not move \"%s\" to \"%s\" (Error: %s)"
msgstr "Error: Could not move \"%s\" to \"%s\" (Error: %s)"
@@ -1581,7 +1581,6 @@ procedure TMainForm.FormDestroy(Sender: TObject);
procedure TMainForm.FormCreate(Sender: TObject);
i, j, MonitorIndex: Integer;
ToolButton: TToolButton;
QueryTab: TQueryTab;
Action: TAction;
dwInfoSize, // Size of VERSIONINFO structure
@@ -1597,6 +1596,8 @@ procedure TMainForm.FormCreate(Sender: TObject);
wine_nt_to_unix_file_name: procedure(p1:pointer; p2:pointer); stdcall;
CoolBand: TCoolBand;
DonateCaptions: TStringList;
OldSnippetsDir, CurrentSnippetsDir, TargetSnippet: String;
Files: TStringDynArray;
caption := APPNAME;

@@ -1658,6 +1659,33 @@ procedure TMainForm.FormCreate(Sender: TObject);
// Ensure directory exists

// Move files from old default snippets directory, see issue #159
if not AppSettings.PortableMode then begin
// This was the default folder up to r5244 / 8b2966c52efb685b00189037a0507157ed03a368
OldSnippetsDir := GetShellFolder(CSIDL_COMMON_APPDATA) + '\' + APPNAME + '\Snippets\';
CurrentSnippetsDir := DirnameSnippets;
if not DirectoryExists(CurrentSnippetsDir) then
if (not OldSnippetsDir.IsEmpty) and (not CurrentSnippetsDir.IsEmpty)
and DirectoryExists(OldSnippetsDir) and DirectoryExists(CurrentSnippetsDir)
and (CompareText(OldSnippetsDir, CurrentSnippetsDir) <> 0)
then begin
Files := TDirectory.GetFiles(OldSnippetsDir, '*.sql');
if Length(Files) > 0 then begin
LogSQL(f_('Migrating snippet files to new folder: %s', [CurrentSnippetsDir]));
for i:=Low(Files) to High(Files) do begin
TargetSnippet := CurrentSnippetsDir + ExtractFileName(Files[i]);
if MoveFile(PChar(Files[i]), PChar(TargetSnippet)) then begin
LogSQL(f_('Successfully moved "%s" to "%s"', [Files[i], TargetSnippet]));
end else begin
LogSQL(f_('Error: Could not move "%s" to "%s" (Error: %s)', [Files[i], TargetSnippet, SysErrorMessage(GetLastError())]), lcError);

// Load snippet filenames

0 comments on commit 424b9f9

Please sign in to comment.
You can’t perform that action at this time.