Display size of SQL file while loading into query editor, so it's easier to decide whether to load or run the file.

This commit is contained in:
Ansgar Becker
2010-05-22 06:34:09 +00:00
parent 58b8f5451d
commit 6468776ba0

View File

@ -4728,6 +4728,7 @@ function TMainForm.QueryLoad( filename: String; ReplaceContent: Boolean = true )
var var
filecontent: String; filecontent: String;
FileSize: Int64;
msgtext: String; msgtext: String;
LineBreaks: TLineBreaks; LineBreaks: TLineBreaks;
RunFileDialog: TRunSQLFileForm; RunFileDialog: TRunSQLFileForm;
@ -4739,10 +4740,12 @@ begin
Exit; Exit;
end; end;
FileSize := _GetFileSize(filename);
// Ask for action when loading a big file // Ask for action when loading a big file
if _GetFileSize( filename ) > 5*SIZE_MB then if FileSize > 5*SIZE_MB then
begin begin
msgtext := 'The file you are about to load is bigger than '+FormatByteNumber(5*SIZE_MB, 0)+'.' + CRLF + CRLF + msgtext := 'The file you are about to load is '+FormatByteNumber(FileSize)+' (> '+FormatByteNumber(5*SIZE_MB, 0)+').' + CRLF + CRLF +
'Do you want to just run the file to avoid loading it completely into the query-editor ( = memory ) ?' + CRLF + CRLF + 'Do you want to just run the file to avoid loading it completely into the query-editor ( = memory ) ?' + CRLF + CRLF +
'Press' + CRLF + 'Press' + CRLF +
' [Yes] to run the file without loading it into the editor' + CRLF + ' [Yes] to run the file without loading it into the editor' + CRLF +
@ -4776,7 +4779,7 @@ begin
Screen.Cursor := crHourGlass; Screen.Cursor := crHourGlass;
if not QueryTabActive then if not QueryTabActive then
PagecontrolMain.ActivePage := tabQuery; PagecontrolMain.ActivePage := tabQuery;
LogSQL('Loading file "'+filename+'" into query tab #'+IntToStr(ActiveQueryTab.Number)+' ...', lcInfo); LogSQL('Loading file "'+filename+'" ('+FormatByteNumber(FileSize)+') into query tab #'+IntToStr(ActiveQueryTab.Number)+' ...', lcInfo);
try try
filecontent := ReadTextfile(filename); filecontent := ReadTextfile(filename);
if Pos( DirnameSnippets, filename ) = 0 then if Pos( DirnameSnippets, filename ) = 0 then