mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +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);
|
||||
function GetShellFolder(FolderId: TGUID): String;
|
||||
function ValidFilename(Str: String): String;
|
||||
function ExtractBaseFileName(FileName: String): String;
|
||||
function FormatNumber( str: String; Thousands: Boolean=True): String; Overload;
|
||||
function UnformatNumber(Val: String): String;
|
||||
function FormatNumber( int: Int64; Thousands: Boolean=True): String; Overload;
|
||||
@ -827,17 +826,6 @@ begin
|
||||
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.
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ interface
|
||||
uses
|
||||
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,
|
||||
loaddata, dbconnection, Vcl.ExtCtrls, gnugettext, dbstructures, System.Math, SynRegExpr;
|
||||
loaddata, dbconnection, Vcl.ExtCtrls, gnugettext, dbstructures, System.Math, SynRegExpr, System.IOUtils;
|
||||
|
||||
type
|
||||
TfrmCsvDetector = class(TExtForm)
|
||||
@ -344,7 +344,7 @@ var
|
||||
TableName: String;
|
||||
begin
|
||||
// Compose CREATE TABLE
|
||||
TableName := ExtractBaseFileName(FLoadDataFrm.editFilename.Text);
|
||||
TableName := TPath.GetFileNameWithoutExtension(FLoadDataFrm.editFilename.Text);
|
||||
TableName := ValidFilename(TableName);
|
||||
Result := 'CREATE TABLE '+FConnection.QuoteIdent(FLoadDataFrm.comboDatabase.Text)+'.'+FConnection.QuoteIdent(TableName)+' (' + sLineBreak;
|
||||
for Col in Columns do begin
|
||||
|
@ -5,7 +5,7 @@ interface
|
||||
uses
|
||||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, ExtCtrls, Menus, ComCtrls, VirtualTrees, SynExportHTML, gnugettext, ActnList,
|
||||
extra_controls, dbstructures, SynRegExpr, System.StrUtils;
|
||||
extra_controls, dbstructures, SynRegExpr, System.StrUtils, System.IOUtils;
|
||||
|
||||
type
|
||||
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!
|
||||
if radioOutputFile.Checked then begin
|
||||
Filename := ExtractFilePath(editFilename.Text) +
|
||||
ExtractBaseFileName(editFilename.Text) +
|
||||
TPath.GetFileNameWithoutExtension(editFilename.Text) +
|
||||
'.' + FormatToFileExtension[ExportFormat];
|
||||
if CompareText(Filename, editFilename.Text) <> 0 then
|
||||
editFilename.Text := Filename;
|
||||
@ -317,7 +317,7 @@ begin
|
||||
Dialog := TSaveDialog.Create(Self);
|
||||
Filename := GetOutputFilename(editFilename.Text, MainForm.ActiveDbObj);
|
||||
Dialog.InitialDir := ExtractFilePath(Filename);
|
||||
Dialog.FileName := ExtractBaseFileName(Filename);
|
||||
Dialog.FileName := TPath.GetFileNameWithoutExtension(Filename);
|
||||
Dialog.Filter := '';
|
||||
for ef:=Low(TGridExportFormat) to High(TGridExportFormat) do
|
||||
Dialog.Filter := Dialog.Filter + FormatToDescription[ef] + ' (*.'+FormatToFileExtension[ef]+')|*.'+FormatToFileExtension[ef]+'|';
|
||||
|
Reference in New Issue
Block a user