ADD: Capability to queue file split operation

This commit is contained in:
Alexander Koblov 2019-01-26 20:23:51 +00:00
commit a7a3b4bb6d
4 changed files with 248 additions and 350 deletions

View file

@ -1,115 +1,207 @@
object frmSplitter: TfrmSplitter
Left = 359
Height = 311
Top = 326
Width = 461
inherited frmSplitter: TfrmSplitter
Left = 920
Height = 247
Top = 374
Width = 500
HorzScrollBar.Page = 464
HorzScrollBar.Range = 369
VertScrollBar.Page = 301
VertScrollBar.Range = 227
ActiveControl = cmbxSize
AutoSize = True
BorderIcons = [biSystemMenu]
Caption = 'Splitter'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ClientHeight = 311
ClientWidth = 461
OnClose = FormClose
ClientHeight = 247
ClientWidth = 500
Constraints.MinWidth = 500
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
Position = poScreenCenter
Position = poOwnerFormCenter
SessionProperties = 'cmbxSize.Text;rbtnByte.Checked;rbtnGigaB.Checked;rbtnKiloB.Checked;rbtnMegaB.Checked;teNumberParts.Text;Width;cbRequireACRC32VerificationFile.Checked'
LCLVersion = '1.8.4.0'
object grbxFile: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = btnCancel
AnchorSideRight.Side = asrBottom
inherited pnlContent: TPanel
Left = 6
Height = 124
Height = 197
Top = 6
Width = 447
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Bottom = 6
Caption = 'File name'
ChildSizing.LeftRightSpacing = 10
ChildSizing.TopBottomSpacing = 4
ClientHeight = 104
ClientWidth = 443
TabOrder = 0
object lbFileSource: TLabel
Left = 10
Height = 15
Top = 4
Width = 56
Caption = 'File &source'
FocusControl = edFileSource
ParentColor = False
end
object lbDirTarget: TLabel
AnchorSideTop.Control = edFileSource
Width = 488
ClientHeight = 197
ClientWidth = 488
object grbxSize: TGroupBox[0]
AnchorSideTop.Control = edDirTarget
AnchorSideTop.Side = asrBottom
Left = 10
AnchorSideRight.Control = pnlContent
AnchorSideRight.Side = asrBottom
Left = -4
Height = 138
Top = 52
Width = 492
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Top = 10
Caption = 'Size and number of parts'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ClientHeight = 118
ClientWidth = 488
Constraints.MinWidth = 300
TabOrder = 1
object cmbxSize: TComboBoxAutoWidth
AnchorSideLeft.Control = grbxSize
AnchorSideTop.Control = grbxSize
Left = 6
Height = 23
Top = 6
Width = 338
DropDownCount = 16
ItemHeight = 15
Items.Strings = (
'Automatic'
'1457664B - 3.5" High Density 1.44M'
'1213952B - 5.25" High Density 1.2M'
'730112B - 3.5" Double Density 720K'
'362496B - 5.25" Double Density 360K'
'98078KB - ZIP 100MB'
'650MB - CD 650MB'
'700MB - CD 700MB'
'4482MB - DVD+R'
)
OnChange = cmbxSizeChange
TabOrder = 0
Text = '1457664B - 3.5"'
end
object rbtnByte: TRadioButton
AnchorSideLeft.Control = cmbxSize
AnchorSideTop.Control = cmbxSize
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 31
Width = 48
BorderSpacing.Top = 2
Caption = '&Bytes'
Checked = True
OnChange = rbtnByteChange
TabOrder = 1
TabStop = True
end
object rbtnKiloB: TRadioButton
AnchorSideLeft.Control = rbtnByte
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rbtnByte
Left = 56
Height = 19
Top = 31
Width = 68
BorderSpacing.Left = 2
Caption = '&Kilobytes'
OnChange = rbtnByteChange
TabOrder = 2
end
object rbtnMegaB: TRadioButton
AnchorSideLeft.Control = rbtnKiloB
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rbtnKiloB
Left = 126
Height = 19
Top = 31
Width = 78
BorderSpacing.Left = 2
Caption = '&Megabytes'
OnChange = rbtnByteChange
TabOrder = 3
end
object teNumberParts: TEdit
AnchorSideLeft.Control = lblNumberParts
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rbtnKiloB
AnchorSideTop.Side = asrBottom
Left = 97
Height = 23
Top = 60
Width = 128
BorderSpacing.Left = 4
BorderSpacing.Top = 10
OnChange = teNumberPartsChange
TabOrder = 5
end
object lblNumberParts: TLabel
AnchorSideLeft.Control = rbtnByte
AnchorSideTop.Control = teNumberParts
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 64
Width = 87
Caption = '&Number of parts'
FocusControl = teNumberParts
ParentColor = False
end
object rbtnGigaB: TRadioButton
AnchorSideLeft.Control = rbtnMegaB
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rbtnKiloB
Left = 206
Height = 19
Top = 31
Width = 72
BorderSpacing.Left = 2
Caption = '&Gigabytes'
OnChange = rbtnByteChange
TabOrder = 4
end
object cbRequireACRC32VerificationFile: TCheckBox
AnchorSideLeft.Control = cmbxSize
AnchorSideTop.Control = teNumberParts
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 93
Width = 188
BorderSpacing.Top = 10
Caption = 'Require a CRC32 verification file'
Checked = True
State = cbChecked
TabOrder = 6
end
end
object lbDirTarget: TLabel[1]
AnchorSideTop.Control = pnlContent
Left = 0
Height = 15
Top = 58
Width = 82
BorderSpacing.Top = 12
Caption = 'Directory &target'
Top = 0
Width = 129
Caption = 'Split the file to directory:'
FocusControl = edDirTarget
ParentColor = False
end
object edFileSource: TEdit
AnchorSideTop.Control = lbFileSource
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 10
Height = 23
Top = 23
Width = 422
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
ReadOnly = True
TabOrder = 0
end
object edDirTarget: TEdit
object edDirTarget: TDirectoryEdit[2]
AnchorSideTop.Control = lbDirTarget
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = btnFTChoice
Left = 10
AnchorSideRight.Control = btnRelativeFTChoice
Left = 0
Height = 23
Top = 77
Width = 372
Top = 19
Width = 462
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 4
TabOrder = 1
MaxLength = 0
TabOrder = 0
end
object btnFTChoice: TButton
object btnRelativeFTChoice: TSpeedButton[3]
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edDirTarget
AnchorSideRight.Control = btnRelativeFTChoice
AnchorSideBottom.Control = edDirTarget
AnchorSideBottom.Side = asrBottom
Left = 382
Height = 23
Top = 77
Width = 24
Anchors = [akTop, akRight, akBottom]
Caption = '...'
OnClick = btnFTChoiceClick
TabOrder = 2
end
object btnRelativeFTChoice: TSpeedButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = edDirTarget
AnchorSideRight.Control = edFileSource
AnchorSideRight.Control = pnlContent
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = edDirTarget
AnchorSideBottom.Side = asrBottom
Left = 406
Left = 462
Height = 23
Hint = 'Some functions to select appropriate path'
Top = 77
Top = 19
Width = 26
Anchors = [akTop, akRight, akBottom]
Glyph.Data = {
@ -151,180 +243,23 @@ object frmSplitter: TfrmSplitter
OnClick = btnRelativeFTChoiceClick
end
end
object grbxSize: TGroupBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = grbxFile
AnchorSideTop.Side = asrBottom
inherited pnlButtons: TPanel
Left = 6
Height = 138
Top = 136
Width = 362
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Right = 6
Caption = 'Size and number of parts'
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ClientHeight = 118
ClientWidth = 358
Constraints.MinWidth = 300
TabOrder = 1
object cmbxSize: TComboBox
AnchorSideLeft.Control = grbxSize
AnchorSideTop.Control = grbxSize
AnchorSideRight.Side = asrBottom
Left = 6
Height = 23
Top = 6
Width = 338
Anchors = [akTop, akLeft, akRight]
DropDownCount = 16
ItemHeight = 15
Items.Strings = (
'Automatic'
'1457664B - 3.5" High Density 1.44M'
'1213952B - 5.25" High Density 1.2M'
'730112B - 3.5" Double Density 720K'
'362496B - 5.25" Double Density 360K'
'98078KB - ZIP 100MB'
'650MB - CD 650MB'
'700MB - CD 700MB'
'4482MB - DVD+R'
)
OnChange = cmbxSizeChange
TabOrder = 0
Text = '1457664B - 3.5"'
Top = 207
Width = 488
ClientWidth = 488
inherited btnCancel: TBitBtn
Left = 306
end
object rbtnByte: TRadioButton
AnchorSideLeft.Control = cmbxSize
AnchorSideTop.Control = cmbxSize
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 31
Width = 48
BorderSpacing.Top = 2
Caption = '&Bytes'
Checked = True
OnChange = rbtnByteChange
TabOrder = 1
TabStop = True
end
object rbtnKiloB: TRadioButton
AnchorSideLeft.Control = rbtnByte
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rbtnByte
Left = 56
Height = 19
Top = 31
Width = 68
BorderSpacing.Left = 2
Caption = '&Kilobytes'
OnChange = rbtnByteChange
TabOrder = 2
end
object rbtnMegaB: TRadioButton
AnchorSideLeft.Control = rbtnKiloB
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rbtnKiloB
Left = 126
Height = 19
Top = 31
Width = 78
BorderSpacing.Left = 2
Caption = '&Megabytes'
OnChange = rbtnByteChange
TabOrder = 3
end
object teNumberParts: TEdit
AnchorSideLeft.Control = lblNumberParts
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rbtnKiloB
AnchorSideTop.Side = asrBottom
Left = 97
Height = 23
Top = 60
Width = 128
BorderSpacing.Left = 4
BorderSpacing.Top = 10
OnChange = teNumberPartsChange
TabOrder = 4
end
object lblNumberParts: TLabel
AnchorSideLeft.Control = rbtnByte
AnchorSideTop.Control = teNumberParts
AnchorSideTop.Side = asrCenter
Left = 6
Height = 15
Top = 64
Width = 87
Caption = '&Number of parts'
FocusControl = teNumberParts
ParentColor = False
end
object rbtnGigaB: TRadioButton
AnchorSideLeft.Control = rbtnMegaB
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = rbtnKiloB
Left = 206
Height = 19
Top = 31
Width = 72
BorderSpacing.Left = 2
Caption = '&Gigabytes'
OnChange = rbtnByteChange
TabOrder = 5
end
object cbRequireACRC32VerificationFile: TCheckBox
AnchorSideLeft.Control = cmbxSize
AnchorSideTop.Control = teNumberParts
AnchorSideTop.Side = asrBottom
Left = 6
Height = 19
Top = 93
Width = 188
BorderSpacing.Top = 10
Caption = 'Require a CRC32 verification file'
Checked = True
State = cbChecked
TabOrder = 6
inherited btnOK: TBitBtn
Left = 400
end
end
object btnOK: TButton
AnchorSideRight.Control = btnCancel
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = btnCancel
Left = 378
Height = 32
Top = 204
Width = 75
Anchors = [akRight, akBottom]
BorderSpacing.Bottom = 6
Caption = '&OK'
Default = True
OnClick = btnOKClick
TabOrder = 2
inherited pmQueuePopup: TPopupMenu
left = 192
end
object btnCancel: TButton
AnchorSideLeft.Control = grbxSize
AnchorSideLeft.Side = asrBottom
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = grbxSize
AnchorSideBottom.Side = asrBottom
Left = 378
Height = 32
Top = 242
Width = 75
Anchors = [akLeft, akBottom]
BorderSpacing.Left = 10
Cancel = True
Caption = '&Cancel'
ModalResult = 2
TabOrder = 3
end
object pmPathHelper: TPopupMenu
left = 408
top = 128
object pmPathHelper: TPopupMenu[3]
left = 368
top = 104
end
end

View file

@ -1,10 +1,5 @@
{"version":1,"strings":[
{"hash":120635234,"name":"tfrmsplitter.caption","sourcebytes":[83,112,108,105,116,116,101,114],"value":"Splitter"},
{"hash":41356085,"name":"tfrmsplitter.grbxfile.caption","sourcebytes":[70,105,108,101,32,110,97,109,101],"value":"File name"},
{"hash":156692405,"name":"tfrmsplitter.lbfilesource.caption","sourcebytes":[70,105,108,101,32,38,115,111,117,114,99,101],"value":"File &source"},
{"hash":123018836,"name":"tfrmsplitter.lbdirtarget.caption","sourcebytes":[68,105,114,101,99,116,111,114,121,32,38,116,97,114,103,101,116],"value":"Directory &target"},
{"hash":12558,"name":"tfrmsplitter.btnftchoice.caption","sourcebytes":[46,46,46],"value":"..."},
{"hash":15252584,"name":"tfrmsplitter.btnrelativeftchoice.hint","sourcebytes":[83,111,109,101,32,102,117,110,99,116,105,111,110,115,32,116,111,32,115,101,108,101,99,116,32,97,112,112,114,111,112,114,105,97,116,101,32,112,97,116,104],"value":"Some functions to select appropriate path"},
{"hash":136166403,"name":"tfrmsplitter.grbxsize.caption","sourcebytes":[83,105,122,101,32,97,110,100,32,110,117,109,98,101,114,32,111,102,32,112,97,114,116,115],"value":"Size and number of parts"},
{"hash":173739330,"name":"tfrmsplitter.cmbxsize.text","sourcebytes":[49,52,53,55,54,54,52,66,32,45,32,51,46,53,34],"value":"1457664B - 3.5\""},
{"hash":44698307,"name":"tfrmsplitter.rbtnbyte.caption","sourcebytes":[38,66,121,116,101,115],"value":"&Bytes"},
@ -13,6 +8,6 @@
{"hash":200834339,"name":"tfrmsplitter.lblnumberparts.caption","sourcebytes":[38,78,117,109,98,101,114,32,111,102,32,112,97,114,116,115],"value":"&Number of parts"},
{"hash":226273075,"name":"tfrmsplitter.rbtngigab.caption","sourcebytes":[38,71,105,103,97,98,121,116,101,115],"value":"&Gigabytes"},
{"hash":118175221,"name":"tfrmsplitter.cbrequireacrc32verificationfile.caption","sourcebytes":[82,101,113,117,105,114,101,32,97,32,67,82,67,51,50,32,118,101,114,105,102,105,99,97,116,105,111,110,32,102,105,108,101],"value":"Require a CRC32 verification file"},
{"hash":11067,"name":"tfrmsplitter.btnok.caption","sourcebytes":[38,79,75],"value":"&OK"},
{"hash":177752476,"name":"tfrmsplitter.btncancel.caption","sourcebytes":[38,67,97,110,99,101,108],"value":"&Cancel"}
{"hash":101971834,"name":"tfrmsplitter.lbdirtarget.caption","sourcebytes":[83,112,108,105,116,32,116,104,101,32,102,105,108,101,32,116,111,32,100,105,114,101,99,116,111,114,121,58],"value":"Split the file to directory:"},
{"hash":15252584,"name":"tfrmsplitter.btnrelativeftchoice.hint","sourcebytes":[83,111,109,101,32,102,117,110,99,116,105,111,110,115,32,116,111,32,115,101,108,101,99,116,32,97,112,112,114,111,112,114,105,97,116,101,32,112,97,116,104],"value":"Some functions to select appropriate path"}
]}

View file

@ -3,7 +3,7 @@
-------------------------------------------------------------------------
Take a single file and split it in part based on few parameters.
Copyright (C) 2018 Alexander Koblov (alexx2000@mail.ru)
Copyright (C) 2007-2018 Alexander Koblov (alexx2000@mail.ru)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -17,17 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Original comment:
-----------------
Seksi Commander
----------------------------
Licence : GNU GPL v 2.0
Author : Pavel Letko (letcuv@centrum.cz)
File splitter
contributors:
Radek Cervinka
}
unit fSplitter;
@ -39,32 +28,27 @@ interface
uses
//Lazarus, Free-Pascal, etc.
SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, Buttons, Menus,
EditBtn, ExtCtrls,
//DC
uFileSource, uFile;
fButtonForm, uFileSource, uFile, KASComboBox;
type
{ TfrmSplitter }
TfrmSplitter = class(TForm)
teNumberParts: TEdit;
grbxFile: TGroupBox;
edFileSource: TEdit;
lblNumberParts: TLabel;
lbFileSource: TLabel;
edDirTarget: TEdit;
TfrmSplitter = class(TfrmButtonForm)
btnRelativeFTChoice: TSpeedButton;
edDirTarget: TDirectoryEdit;
lbDirTarget: TLabel;
btnFTChoice: TButton;
teNumberParts: TEdit;
lblNumberParts: TLabel;
grbxSize: TGroupBox;
cmbxSize: TComboBox;
btnOK: TButton;
btnCancel: TButton;
cmbxSize: TComboBoxAutoWidth;
rbtnKiloB: TRadioButton;
rbtnMegaB: TRadioButton;
rbtnGigaB: TRadioButton;
rbtnByte: TRadioButton;
btnRelativeFTChoice: TSpeedButton;
cbRequireACRC32VerificationFile: TCheckBox;
pmPathHelper: TPopupMenu;
procedure btnFTChoiceClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure SetNumberOfPart;
procedure SetSizeOfPart;
@ -72,21 +56,19 @@ type
procedure btnRelativeFTChoiceClick(Sender: TObject);
procedure rbtnByteChange(Sender: TObject);
procedure teNumberPartsChange(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure FormClose(Sender: TObject; var {%H-}CloseAction: TCloseAction);
private
{ Private declarations }
FFileName: String;
iVolumeSize: Int64;
MyModalResult: integer;
iVolumeNumber: Integer;
function StrConvert(sExpression: String): Int64;
public
{ Public declarations }
iVolumeNumber: Integer;
iVolumeSize: int64;
end;
{ ShowSplitterFileForm:
"TMainCommands.cm_FileSpliter" function from "uMainCommands.pas" is calling this routine.}
function ShowSplitterFileForm(aFileSource: IFileSource; var aFile: TFile; const TargetPath: String): Boolean;
function ShowSplitterFileForm(TheOwner: TComponent; aFileSource: IFileSource; var aFile: TFile; const TargetPath: String): Boolean;
implementation
@ -102,14 +84,14 @@ uses
{ ShowSplitterFileForm:
"TMainCommands.cm_FileSpliter" function from "uMainCommands.pas" is calling this routine.}
function ShowSplitterFileForm(aFileSource: IFileSource; var aFile: TFile; const TargetPath: String): Boolean;
function ShowSplitterFileForm(TheOwner: TComponent; aFileSource: IFileSource; var aFile: TFile; const TargetPath: String): Boolean;
var
Operation: TFileSourceSplitOperation = nil;
frmSplitter:TfrmSplitter;
Operation: TFileSourceSplitOperation = nil;
begin
frmSplitter:=TfrmSplitter.Create(Application); //Did not use the "with..." here to make absolutely sure of what is referenced in the following.
frmSplitter:=TfrmSplitter.Create(TheOwner); //Did not use the "with..." here to make absolutely sure of what is referenced in the following.
try
frmSplitter.edFileSource.Text:= aFile.FullPath;
frmSplitter.FFileName:= aFile.FullPath;
frmSplitter.edDirTarget.Text:= TargetPath;
frmSplitter.SetNumberOfPart;
@ -126,10 +108,10 @@ begin
Operation.VolumeNumber:= frmSplitter.iVolumeNumber;
Operation.RequireACRC32VerificationFile:= frmSplitter.cbRequireACRC32VerificationFile.Checked;
Operation.AutomaticSplitMode:=(frmSplitter.cmbxSize.ItemIndex=0);
OperationsManager.AddOperation(Operation);
OperationsManager.AddOperation(Operation, frmSplitter.QueueIdentifier, False);
end;
finally
FreeThenNil(aFile);
FreeAndNil(aFile);
end;
end;
finally
@ -144,10 +126,10 @@ begin
begin
if StrConvert(cmbxSize.Text)>0 then
begin
if mbFileSize(edFileSource.Text) mod StrConvert(cmbxSize.Text)>0 then
teNumberParts.Text:= IntToStr( (mbFileSize(edFileSource.Text) div StrConvert(cmbxSize.Text)) +1)
if mbFileSize(FFileName) mod StrConvert(cmbxSize.Text)>0 then
teNumberParts.Text:= IntToStr( (mbFileSize(FFileName) div StrConvert(cmbxSize.Text)) +1)
else
teNumberParts.Text:= IntToStr(mbFileSize(edFileSource.Text) div StrConvert(cmbxSize.Text));
teNumberParts.Text:= IntToStr(mbFileSize(FFileName) div StrConvert(cmbxSize.Text));
end
else
begin
@ -165,10 +147,10 @@ procedure TfrmSplitter.SetSizeOfPart;
begin
if StrToInt64Def(teNumberParts.Text,0)>0 then
begin
if mbFileSize(edFileSource.Text) mod StrToInt64Def(teNumberParts.Text,0)>0 then
cmbxSize.Text := IntToStr(mbFileSize(edFileSource.Text) div StrToInt64Def(teNumberParts.Text, 0) + 1)
if mbFileSize(FFileName) mod StrToInt64Def(teNumberParts.Text,0)>0 then
cmbxSize.Text := IntToStr(mbFileSize(FFileName) div StrToInt64Def(teNumberParts.Text, 0) + 1)
else
cmbxSize.Text := IntToStr(mbFileSize(edFileSource.Text) div StrToInt64Def(teNumberParts.Text, 0));
cmbxSize.Text := IntToStr(mbFileSize(FFileName) div StrToInt64Def(teNumberParts.Text, 0));
rbtnByte.Checked := True;
rbtnByte.Enabled := True;
rbtnKiloB.Enabled := True;
@ -181,22 +163,9 @@ begin
end;
end;
{ TfrmSplitter.btnFTChoiceClick }
procedure TfrmSplitter.btnFTChoiceClick(Sender: TObject);
var
sDir: string;
begin
if SelectDirectory(rsSplitSelDir, edDirTarget.Text, sDir) then
// Select directory:
// must change on linux!!!
begin
edDirTarget.Text:= sDir;
end;
end;
{ TfrmSplitter.StrConvert }
//Let's do a basic conversion that maybe is not a full idiot-proof, but versatile and simple enough to fit in a few lines.
function TfrmSplitter.StrConvert(sExpression:string):int64;
function TfrmSplitter.StrConvert(sExpression: String): Int64;
var
iMult: int64 = 1;
bUseRadioButtons: boolean = True;
@ -259,8 +228,7 @@ begin
end;
//7.Since we're now supposed to have just numbers in our string, we should be ready to do our conversion.
result := StrToInt64Def(sExpression, 0) * iMult;
Result := StrToInt64Def(sExpression, 0) * iMult;
end;
{ TfrmSplitter.FormCreate }
@ -341,51 +309,51 @@ begin
if teNumberParts.Focused then SetSizeOfPart; //Do the function ONLY-IF it's the result of someone typing in the field
end;
{ TfrmSplitter.btnOKClick }
procedure TfrmSplitter.btnOKClick(Sender: TObject);
{ TfrmSplitter.FormCloseQuery }
procedure TfrmSplitter.FormCloseQuery(Sender: TObject; var CanClose: boolean);
var
isTooManyFiles: boolean;
begin
if cmbxSize.ItemIndex<>0 then iVolumeSize:= StrConvert(cmbxSize.Text) else iVolumeSize:=0;
if (iVolumeSize <= 0) AND (cmbxSize.ItemIndex<>0) then
if (ModalResult <> mrCancel) then
begin
ShowMessageBox(rsSplitErrFileSize, rsSimpleWordError+'!', MB_OK or MB_ICONERROR); //Incorrect file size format! (Used "ShowMessageBox" instead of "MsgError" 'cause with "MsgError", user can still click on the frmSplitter form and type in it).
end
else
begin
if not mbForceDirectory(IncludeTrailingPathDelimiter(mbExpandFileName(edDirTarget.Text))) then
if cmbxSize.ItemIndex <> 0 then
iVolumeSize:= StrConvert(cmbxSize.Text)
else begin
iVolumeSize:= 0;
end;
if (iVolumeSize <= 0) AND (cmbxSize.ItemIndex<>0) then
begin
ShowMessageBox(rsSplitErrDirectory, rsSimpleWordError+'!', MB_OK or MB_ICONERROR); //Unable to create target directory!
ShowMessageBox(rsSplitErrFileSize, rsSimpleWordError+'!', MB_OK or MB_ICONERROR); //Incorrect file size format! (Used "ShowMessageBox" instead of "MsgError" 'cause with "MsgError", user can still click on the frmSplitter form and type in it).
end
else
begin
if teNumberParts.Text <> rsMSgUndeterminedNumberOfFile then iVolumeNumber := StrToInt(teNumberParts.Text) else iVolumeNumber := 0;
if (iVolumeNumber < 1) AND (teNumberParts.Text <> rsMSgUndeterminedNumberOfFile) then
if not mbForceDirectory(IncludeTrailingPathDelimiter(mbExpandFileName(edDirTarget.Text))) then
begin
ShowMessageBox(rsSplitErrSplitFile, rsSimpleWordError+'!', MB_OK or MB_ICONERROR); //Unable to split the file!
ShowMessageBox(rsSplitErrDirectory, rsSimpleWordError+'!', MB_OK or MB_ICONERROR); //Unable to create target directory!
end
else
begin
isTooManyFiles:=(iVolumeNumber > 100);
if isTooManyFiles then isTooManyFiles:=(MessageDlg(Caption, rsSplitMsgManyParts, mtWarning, mbYesNo, 0) <> mrYes);
if not isTooManyFiles then
if teNumberParts.Text <> rsMSgUndeterminedNumberOfFile then iVolumeNumber := StrToInt(teNumberParts.Text) else iVolumeNumber := 0;
if (iVolumeNumber < 1) AND (teNumberParts.Text <> rsMSgUndeterminedNumberOfFile) then
begin
MyModalResult:=mrOk;
close;
end; //if isTooManyFiles then
end; //if (iVolumeNumber = 0) then
end; //if not mbForceDirectory(edDirTarget.Text) then
end; //if iVolumeSize <= 0 then
end;
ShowMessageBox(rsSplitErrSplitFile, rsSimpleWordError+'!', MB_OK or MB_ICONERROR); //Unable to split the file!
end
else
begin
isTooManyFiles:=(iVolumeNumber > 100);
if isTooManyFiles then isTooManyFiles:=(MessageDlg(Caption, rsSplitMsgManyParts, mtWarning, mbYesNo, 0) <> mrYes);
{ TfrmSplitter.FormClose }
procedure TfrmSplitter.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
modalResult := MyModalResult;
if not isTooManyFiles then
begin
MyModalResult:= mrOk;
end; //if isTooManyFiles then
end; //if (iVolumeNumber = 0) then
end; //if not mbForceDirectory(edDirTarget.Text) then
end; //if iVolumeSize <= 0 then
CanClose:= (MyModalResult = mrOK);
end;
ModalResult := MyModalResult;
end;
end.

View file

@ -3924,9 +3924,9 @@ begin
if (not Assigned(aFile)) or (aFile.IsDirectory or aFile.IsLinkToDirectory) then
msgWarning(rsMsgInvalidSelection)
else
ShowSplitterFileForm(FileSource, aFile, NotActiveFrame.CurrentPath);
ShowSplitterFileForm(frmMain, FileSource, aFile, NotActiveFrame.CurrentPath);
finally
FreeThenNil(aFile);
FreeAndNil(aFile);
end; // try
end; // with
end;