mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 10:02:10 +08:00
Replace redundant ExtractBaseFileName() with TPath.GetFileNameWithoutExtension()
This commit is contained in:
@ -302,7 +302,6 @@ type
|
|||||||
procedure RemoveNullChars(var Text: String; var HasNulls: Boolean);
|
procedure RemoveNullChars(var Text: String; var HasNulls: Boolean);
|
||||||
function GetShellFolder(FolderId: TGUID): String;
|
function GetShellFolder(FolderId: TGUID): String;
|
||||||
function ValidFilename(Str: String): String;
|
function ValidFilename(Str: String): String;
|
||||||
function ExtractBaseFileName(FileName: String): String;
|
|
||||||
function FormatNumber( str: String; Thousands: Boolean=True): String; Overload;
|
function FormatNumber( str: String; Thousands: Boolean=True): String; Overload;
|
||||||
function UnformatNumber(Val: String): String;
|
function UnformatNumber(Val: String): String;
|
||||||
function FormatNumber( int: Int64; Thousands: Boolean=True): String; Overload;
|
function FormatNumber( int: Int64; Thousands: Boolean=True): String; Overload;
|
||||||
@ -827,17 +826,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function ExtractBaseFileName(FileName: String): String;
|
|
||||||
var
|
|
||||||
Ext: String;
|
|
||||||
begin
|
|
||||||
// Extract file name without path and file extension
|
|
||||||
FileName := ExtractFileName(FileName);
|
|
||||||
Ext := ExtractFileExt(FileName);
|
|
||||||
Result := Copy(FileName, 1, Length(FileName)-Length(Ext));
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{**
|
{**
|
||||||
Unformat a formatted integer or float. Used for CSV export and composing WHERE clauses for grid editing.
|
Unformat a formatted integer or float. Used for CSV export and composing WHERE clauses for grid editing.
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
|
||||||
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SynEdit, SynMemo, extra_controls, apphelpers,
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, SynEdit, SynMemo, extra_controls, apphelpers,
|
||||||
loaddata, dbconnection, Vcl.ExtCtrls, gnugettext, dbstructures, System.Math, SynRegExpr;
|
loaddata, dbconnection, Vcl.ExtCtrls, gnugettext, dbstructures, System.Math, SynRegExpr, System.IOUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
TfrmCsvDetector = class(TExtForm)
|
TfrmCsvDetector = class(TExtForm)
|
||||||
@ -344,7 +344,7 @@ var
|
|||||||
TableName: String;
|
TableName: String;
|
||||||
begin
|
begin
|
||||||
// Compose CREATE TABLE
|
// Compose CREATE TABLE
|
||||||
TableName := ExtractBaseFileName(FLoadDataFrm.editFilename.Text);
|
TableName := TPath.GetFileNameWithoutExtension(FLoadDataFrm.editFilename.Text);
|
||||||
TableName := ValidFilename(TableName);
|
TableName := ValidFilename(TableName);
|
||||||
Result := 'CREATE TABLE '+FConnection.QuoteIdent(FLoadDataFrm.comboDatabase.Text)+'.'+FConnection.QuoteIdent(TableName)+' (' + sLineBreak;
|
Result := 'CREATE TABLE '+FConnection.QuoteIdent(FLoadDataFrm.comboDatabase.Text)+'.'+FConnection.QuoteIdent(TableName)+' (' + sLineBreak;
|
||||||
for Col in Columns do begin
|
for Col in Columns do begin
|
||||||
|
@ -5,7 +5,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||||
Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls, VirtualTrees, SynExportHTML, gnugettext, ActnList,
|
Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls, VirtualTrees, SynExportHTML, gnugettext, ActnList,
|
||||||
extra_controls, dbstructures, SynRegExpr, System.StrUtils;
|
extra_controls, dbstructures, SynRegExpr, System.StrUtils, System.IOUtils;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGridExportFormat = (efExcel, efCSV, efHTML, efXML, efSQLInsert, efSQLReplace, efSQLDeleteInsert, efSQLUpdate, efLaTeX, efTextile, efJiraTextile, efPHPArray, efMarkDown, efJSON);
|
TGridExportFormat = (efExcel, efCSV, efHTML, efXML, efSQLInsert, efSQLReplace, efSQLDeleteInsert, efSQLUpdate, efLaTeX, efTextile, efJiraTextile, efPHPArray, efMarkDown, efJSON);
|
||||||
@ -274,7 +274,7 @@ begin
|
|||||||
// Be careful about triggering editFilename.OnChange event, as we may have come here from that event!
|
// Be careful about triggering editFilename.OnChange event, as we may have come here from that event!
|
||||||
if radioOutputFile.Checked then begin
|
if radioOutputFile.Checked then begin
|
||||||
Filename := ExtractFilePath(editFilename.Text) +
|
Filename := ExtractFilePath(editFilename.Text) +
|
||||||
ExtractBaseFileName(editFilename.Text) +
|
TPath.GetFileNameWithoutExtension(editFilename.Text) +
|
||||||
'.' + FormatToFileExtension[ExportFormat];
|
'.' + FormatToFileExtension[ExportFormat];
|
||||||
if CompareText(Filename, editFilename.Text) <> 0 then
|
if CompareText(Filename, editFilename.Text) <> 0 then
|
||||||
editFilename.Text := Filename;
|
editFilename.Text := Filename;
|
||||||
@ -317,7 +317,7 @@ begin
|
|||||||
Dialog := TSaveDialog.Create(Self);
|
Dialog := TSaveDialog.Create(Self);
|
||||||
Filename := GetOutputFilename(editFilename.Text, MainForm.ActiveDbObj);
|
Filename := GetOutputFilename(editFilename.Text, MainForm.ActiveDbObj);
|
||||||
Dialog.InitialDir := ExtractFilePath(Filename);
|
Dialog.InitialDir := ExtractFilePath(Filename);
|
||||||
Dialog.FileName := ExtractBaseFileName(Filename);
|
Dialog.FileName := TPath.GetFileNameWithoutExtension(Filename);
|
||||||
Dialog.Filter := '';
|
Dialog.Filter := '';
|
||||||
for ef:=Low(TGridExportFormat) to High(TGridExportFormat) do
|
for ef:=Low(TGridExportFormat) to High(TGridExportFormat) do
|
||||||
Dialog.Filter := Dialog.Filter + FormatToDescription[ef] + ' (*.'+FormatToFileExtension[ef]+')|*.'+FormatToFileExtension[ef]+'|';
|
Dialog.Filter := Dialog.Filter + FormatToDescription[ef] + ' (*.'+FormatToFileExtension[ef]+')|*.'+FormatToFileExtension[ef]+'|';
|
||||||
|
Reference in New Issue
Block a user