mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Migrate files from old default snippets directory. Closes #159
This commit is contained in:
@ -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 <anse@heidisql.com>\n"
|
||||
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\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 @@ end;
|
||||
procedure TMainForm.FormCreate(Sender: TObject);
|
||||
var
|
||||
i, j, MonitorIndex: Integer;
|
||||
ToolButton: TToolButton;
|
||||
QueryTab: TQueryTab;
|
||||
Action: TAction;
|
||||
dwInfoSize, // Size of VERSIONINFO structure
|
||||
@ -1597,6 +1596,8 @@ var
|
||||
wine_nt_to_unix_file_name: procedure(p1:pointer; p2:pointer); stdcall;
|
||||
CoolBand: TCoolBand;
|
||||
DonateCaptions: TStringList;
|
||||
OldSnippetsDir, CurrentSnippetsDir, TargetSnippet: String;
|
||||
Files: TStringDynArray;
|
||||
begin
|
||||
caption := APPNAME;
|
||||
|
||||
@ -1658,6 +1659,33 @@ begin
|
||||
// Ensure directory exists
|
||||
ForceDirectories(DirnameUserAppData);
|
||||
|
||||
// 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
|
||||
ForceDirectories(CurrentSnippetsDir);
|
||||
//showmessage('1:'+crlf+OldSnippetsDir+crlf+CurrentSnippetsDir);
|
||||
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);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// Load snippet filenames
|
||||
SetSnippetFilenames;
|
||||
|
||||
|
Reference in New Issue
Block a user