mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
Fix: [ 1663717 ] падает при отсутствии ini файла
This commit is contained in:
parent
46e8b4c17a
commit
cfcf10468d
13 changed files with 221 additions and 284 deletions
|
|
@ -5,6 +5,7 @@ del /Q *.or
|
|||
del /Q *.*~
|
||||
del /Q *.~*
|
||||
del /Q doublecmd*.exe
|
||||
del /Q doublecmd.compiled
|
||||
|
||||
del /Q plugins\cpio\bin\*.*
|
||||
del /Q plugins\rpm\bin\*.*
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
strip --strip-all doublecmd.exe
|
||||
upx --best --lzma doublecmd.exe
|
||||
upx --9 doublecmd.exe
|
||||
2
_pack.sh
Normal file
2
_pack.sh
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
#/bin/sh
|
||||
strip --strip-all doublecmd
|
||||
113
doublecmd.ini
113
doublecmd.ini
|
|
@ -1,54 +1,59 @@
|
|||
Language=english.lng
|
||||
LynxLike=1
|
||||
CaseSensitiveSort=1
|
||||
ShowSystemFiles=1
|
||||
DirSelect=1
|
||||
Term=cmd.exe
|
||||
HotDir=/home/,/mnt/,/usr/bin/,/mnt/X//
|
||||
ShortFileSizeFormat=1
|
||||
UseExtEdit=0
|
||||
UseExtView=0
|
||||
UseExtDiff=0
|
||||
ExtEdit=kwrite "%s"
|
||||
ExtView=Viewer.exe "%s"
|
||||
RunTerm=cmd.exe
|
||||
FontSize=9
|
||||
FontWeight=700
|
||||
FontEditorSize=12
|
||||
FontViewerSize=12
|
||||
FontName=MS Sans Serif
|
||||
FontViewerName=Courier
|
||||
FontEditorName=Times New Roman
|
||||
SeparateExt=1
|
||||
EditorSize=12
|
||||
ViewerSize=12
|
||||
Main.Left=-87
|
||||
Main.Top=48
|
||||
Main.Width=800
|
||||
Main.Height=541
|
||||
Col0=169
|
||||
Col1=33
|
||||
Col2=48
|
||||
Col3=76
|
||||
Col4=216
|
||||
Viewer.left=3634
|
||||
Viewer.top=13363
|
||||
Viewer.height=100
|
||||
Viewer.width=350
|
||||
Editor.left=82
|
||||
Editor.top=340
|
||||
Editor.height=518
|
||||
Editor.width=792
|
||||
leftpath=c:\
|
||||
rightpath=c:\
|
||||
|
||||
|
||||
[Colors]
|
||||
BackColor=16777215
|
||||
|
||||
[PackerPlugins]
|
||||
;rpm=20,X:\Doublecmd\plugins\rpm\bin\rpm.wcx
|
||||
;zip=87,E:\Doublecmd\Internet\Doublecmd\plugins\zip\bin\zip.wcx
|
||||
;tar=87,X:\Doublecmd\plugins\zip\bin\zip.wcx
|
||||
;gz=87,X:\Doublecmd\plugins\zip\bin\zip.wcx
|
||||
;cpio=87,X:\Doublecmd\plugins\cpio\bin\cpio.wcx
|
||||
[Configuration]
|
||||
Language=english.lng
|
||||
LynxLike=1
|
||||
CaseSensitiveSort=1
|
||||
ShowSystemFiles=1
|
||||
DirSelect=1
|
||||
Term=/usr/X11R6/bin/xterm -e bash -i -c %s
|
||||
HotDir=/home/,/mnt/,/usr/bin/,/mnt/X//
|
||||
ShortFileSizeFormat=1
|
||||
UseExtEdit=0
|
||||
UseExtView=0
|
||||
UseExtDiff=0
|
||||
ExtEdit=kwrite "%s"
|
||||
ExtView=Viewer.exe "%s"
|
||||
RunTerm=/usr/X11R6/bin/xterm
|
||||
FontSize=9
|
||||
FontWeight=700
|
||||
FontEditorSize=12
|
||||
FontViewerSize=12
|
||||
FontName=MS Sans Serif
|
||||
FontViewerName=Courier
|
||||
FontEditorName=Times New Roman
|
||||
SeparateExt=1
|
||||
EditorSize=12
|
||||
ViewerSize=12
|
||||
Main.Left=-2
|
||||
Main.Top=61
|
||||
Main.Width=800
|
||||
Main.Height=546
|
||||
Col0=169
|
||||
Col1=33
|
||||
Col2=48
|
||||
Col3=76
|
||||
Col4=216
|
||||
Viewer.left=4306
|
||||
Viewer.top=15939
|
||||
Viewer.height=100
|
||||
Viewer.width=350
|
||||
Editor.left=252
|
||||
Editor.top=993
|
||||
Editor.height=518
|
||||
Editor.width=792
|
||||
|
||||
[Colors]
|
||||
BackColor=16777215
|
||||
|
||||
[PackerPlugins]
|
||||
;rpm=20,X:\Doublecmd\plugins\rpm\bin\rpm.wcx
|
||||
zip=87,X:\DC\svn\doublecmd\plugins\zip\bin\zip.wcx
|
||||
;tar=87,X:\Doublecmd\plugins\zip\bin\zip.wcx
|
||||
;gz=87,X:\Doublecmd\plugins\zip\bin\zip.wcx
|
||||
;cpio=87,X:\Doublecmd\plugins\cpio\bin\cpio.wcx
|
||||
7z=87,X:\Totalcmd\Plugins\wcx\7zip\7zip.wcx
|
||||
|
||||
[left]
|
||||
path=/root/
|
||||
|
||||
[right]
|
||||
path=/mnt/X/dc/
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ uses
|
|||
uGlobsPaths,
|
||||
uGlobs,
|
||||
uLng,
|
||||
uIni,
|
||||
SysUtils,
|
||||
Forms,
|
||||
fMain,
|
||||
|
|
@ -73,11 +72,13 @@ uses
|
|||
writeln(' and contributors (see about dialog)');
|
||||
|
||||
LoadPaths;
|
||||
LoadGlobs;
|
||||
LoadPixMapManager;
|
||||
Application.CreateForm(TfrmMain, frmMain); // main form
|
||||
Application.CreateForm(TdmHighl, dmHighl); // highlighters
|
||||
Application.Run;
|
||||
if LoadGlobs then
|
||||
begin
|
||||
LoadPixMapManager;
|
||||
Application.CreateForm(TfrmMain, frmMain); // main form
|
||||
Application.CreateForm(TdmHighl, dmHighl); // highlighters
|
||||
Application.Run;
|
||||
end;
|
||||
{ except
|
||||
on E:Exception do
|
||||
Writeln('Critical unhandled exception:', E.Message);
|
||||
|
|
|
|||
30
fmain.pas
30
fmain.pas
|
|
@ -472,14 +472,14 @@ begin
|
|||
for x:=0 to 4 do
|
||||
gColumnSize[x]:=FrameLeft.dgPanel.ColWidths[x];
|
||||
(* Save Paths *)
|
||||
gIni.Value['leftpath'] := FrameLeft.pnlFile.ActiveDir;
|
||||
gIni.Value['rightpath'] := FrameRight.pnlFile.ActiveDir;
|
||||
gIni.WriteString('left', 'path', FrameLeft.pnlFile.ActiveDir);
|
||||
gIni.WriteString('right', 'path', FrameRight.pnlFile.ActiveDir);
|
||||
(* /Save Paths *)
|
||||
|
||||
gIni.Value['Main.Left']:=IntToStr(Left+cLeftBorder);// border!!
|
||||
gIni.Value['Main.Top']:=IntToStr(Top+cTopBorder); // border!!
|
||||
gIni.Value['Main.Width']:=IntToStr(Width);
|
||||
gIni.Value['Main.Height']:=IntToStr(Height);
|
||||
gIni.WriteInteger('Configuration', 'Main.Left', Left+cLeftBorder);// border!!
|
||||
gIni.WriteInteger('Configuration', 'Main.Top', Top+cTopBorder); // border!!
|
||||
gIni.WriteInteger('Configuration', 'Main.Width', Width);
|
||||
gIni.WriteInteger('Configuration', 'Main.Height', Height);
|
||||
end;
|
||||
|
||||
procedure TfrmMain.frmMainKeyUp(Sender: TObject; var Key: Word;
|
||||
|
|
@ -502,14 +502,14 @@ begin
|
|||
(* Restore Paths *)
|
||||
|
||||
{Left panel}
|
||||
LastDir := gIni.Value['leftpath'];
|
||||
LastDir := gIni.ReadString('left', 'path', '');
|
||||
if LastDir <> '' then
|
||||
begin
|
||||
FrameLeft.pnlFile.ActiveDir := LastDir;
|
||||
FrameLeft.pnlFile.LoadPanel;
|
||||
end;
|
||||
{Right panel}
|
||||
LastDir := gIni.Value['rightpath'];
|
||||
LastDir := gIni.ReadString('right', 'path', '');
|
||||
if LastDir <> '' then
|
||||
begin
|
||||
FrameRight.pnlFile.ActiveDir := LastDir;
|
||||
|
|
@ -520,10 +520,10 @@ begin
|
|||
PanelSelected:=fpLeft;
|
||||
|
||||
SetActiveFrame(fpLeft);
|
||||
Left:=StrToIntDef(gIni.Value['Main.Left'], Left);
|
||||
Top:= StrToIntDef(gIni.Value['Main.Top'], Top);
|
||||
Width:= StrToIntDef( gIni.Value['Main.Width'], Width);
|
||||
Height:= StrToIntDef( gIni.Value['Main.Height'], Height);
|
||||
Left := gIni.ReadInteger('Configuration', 'Main.Left', Left);
|
||||
Top := gIni.ReadInteger('Configuration', 'Main.Top', Top);
|
||||
Width := gIni.ReadInteger('Configuration', 'Main.Width', Width);
|
||||
Height := gIni.ReadInteger('Configuration', 'Main.Height', Height);
|
||||
pnlNotebooks.Width:=Width div 2;
|
||||
|
||||
(*Create Disk Panels*)
|
||||
|
|
@ -2194,7 +2194,7 @@ begin
|
|||
ReAlign;
|
||||
pnlFile.LoadPanel;
|
||||
UpDatelblInfo;
|
||||
dgPanel.Color := StrToIntDef(gIni.Value['BackColor'], 0);
|
||||
dgPanel.Color := gIni.ReadInteger('Colors', 'BackColor', 16777215);
|
||||
lblLPath.OnClick:=@FramelblLPathClick;
|
||||
edtRename.OnExit:=@FrameRightedtRenameExit;
|
||||
edtSearch.OnExit:=@FrameedtSearchExit;
|
||||
|
|
@ -2217,9 +2217,9 @@ begin
|
|||
if x = 0 then // First page
|
||||
begin
|
||||
if ANoteBook.Align = alLeft then
|
||||
PageName := GetLastDir(gIni.Value['leftpath'])
|
||||
PageName := GetLastDir(gIni.ReadString('left', 'path', ''))
|
||||
else
|
||||
PageName := GetLastDir(gIni.Value['rightpath']);
|
||||
PageName := GetLastDir(gIni.ReadString('right', 'path', ''));
|
||||
if PageName = '' then
|
||||
PageName := ExtractFileDrive(gpExePath);
|
||||
end
|
||||
|
|
|
|||
|
|
@ -362,3 +362,4 @@
|
|||
2231:size:
|
||||
2232:Select directory:
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,6 @@ interface
|
|||
var
|
||||
|
||||
gpExePath:String ='';
|
||||
{
|
||||
gpIniDir='./'; // local for user
|
||||
gpCfgDir='./'; // global for all user
|
||||
gpLngDir='./lng/'; // path to lng files
|
||||
}
|
||||
|
||||
gpIniDir:String =''; // local for user
|
||||
gpCfgDir:String =''; // global for all user
|
||||
gpLngDir:String =''; // path to lng files
|
||||
|
|
|
|||
23
uOSUtils.pas
23
uOSUtils.pas
|
|
@ -11,7 +11,7 @@ contributors:
|
|||
interface
|
||||
|
||||
uses
|
||||
SysUtils, Classes {$IFDEF WIN32}, Windows, ShellApi, MMSystem{$ELSE}, BaseUnix, Libc{$ENDIF};
|
||||
SysUtils, Classes {$IFDEF WIN32}, Windows, ShellApi, MMSystem{$ELSE}, BaseUnix, Libc, Unix, UnixType{$ENDIF};
|
||||
|
||||
type
|
||||
TDriveType = (dtUnknown, dtNoDrive, dtFloppy, dtFixed, dtNetwork, dtCDROM,
|
||||
|
|
@ -67,6 +67,7 @@ type
|
|||
function FPS_ISDIR(iAttr:Cardinal) : Boolean;
|
||||
function FPS_ISLNK(iAttr:Cardinal) : Boolean;
|
||||
function ExecCmdFork(const sCmd:String):Integer;
|
||||
function GetDiskFreeSpace(Path : String; var FreeSize, TotalSize : Int64) : Boolean;
|
||||
function CreateHardLink(Path, LinkName: string) : Boolean;
|
||||
function CreateSymLink(Path, LinkName: string) : Boolean;
|
||||
function GetHomeDir : String;
|
||||
|
|
@ -129,6 +130,26 @@ ShellExecute(0, 'open',PChar(sCmd), nil, PChar(ExtractFilePath(sCmd)), SW_SHOW);
|
|||
end;
|
||||
{$ENDIF}
|
||||
|
||||
(* Get Disk Free Space *)
|
||||
|
||||
function GetDiskFreeSpace(Path : String; var FreeSize, TotalSize : Int64) : Boolean;
|
||||
{$IFDEF UNIX}
|
||||
var
|
||||
sbfs:Tstatfs;
|
||||
begin
|
||||
statfs(PChar(Path),sbfs);
|
||||
// writeln('Statfs:',sbfs.bavail,' ',sbfs.bsize,' ',sbfs.blocks,' ', sbfs.bfree);
|
||||
FreeSize := (Int64(sbfs.bavail)*sbfs.bsize);
|
||||
TotalSize := (Int64(sbfs.blocks)*sbfs.bsize);
|
||||
end;
|
||||
{$ELSE}
|
||||
begin
|
||||
Result:= GetDiskFreeSpaceEx(PChar(Path), FreeSize, TotalSize, nil);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
|
||||
|
||||
function CreateHardLink(Path, LinkName: string) : Boolean;
|
||||
{$IFDEF WIN32}
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ implementation
|
|||
uses
|
||||
SysUtils, uFileOp, uGlobs,
|
||||
uShowMsg, Controls, uFilter, uConv, uLng, uShowForm,
|
||||
uOSUtils{$IFNDEF WIN32}, BaseUnix, Unix, UnixType{$ELSE}, Windows{$ENDIF};
|
||||
uOSUtils;
|
||||
|
||||
constructor TFilePanel.Create(APanel:TDrawGrid; AlblPath: TStaticText; AlblCurPath, AlblFree:TLabel; AedtCommand:TComboBox);
|
||||
begin
|
||||
|
|
@ -522,12 +522,8 @@ end;
|
|||
|
||||
procedure TFilePanel.UpdatePrompt;
|
||||
var
|
||||
FreeSize,
|
||||
TotalSize : Int64;
|
||||
{$IFNDEF WIN32}
|
||||
sbfs:Tstatfs;
|
||||
{$ENDIF}
|
||||
// iPathWidth:Integer;
|
||||
FreeSize,
|
||||
TotalSize : Int64;
|
||||
begin
|
||||
with flblCurPath do
|
||||
begin
|
||||
|
|
@ -541,16 +537,8 @@ begin
|
|||
fedtCommand.Width:=TControl(fedtCommand.Parent).Width-fedtCommand.Left;
|
||||
if fPanelMode=pmDirectory then
|
||||
begin
|
||||
{$IFNDEF WIN32}
|
||||
statfs(PChar(fActiveDir),sbfs);
|
||||
// writeln('Statfs:',sbfs.bavail,' ',sbfs.bsize,' ',sbfs.blocks,' ', sbfs.bfree);
|
||||
flblFree.Caption:=Format(lngGetString(clngFreeMsg),
|
||||
[cnvFormatFileSize(Int64(sbfs.bavail)*sbfs.bsize),
|
||||
cnvFormatFileSize(Int64(sbfs.blocks)*sbfs.bsize)]);
|
||||
{$ELSE}
|
||||
if GetDiskFreeSpaceEx(PChar(fActiveDir), FreeSize, TotalSize, nil) then
|
||||
flblFree.Caption:= Format(lngGetString(clngFreeMsg),[cnvFormatFileSize(FreeSize),cnvFormatFileSize(TotalSize)]);
|
||||
{$ENDIF}
|
||||
GetDiskFreeSpace(fActiveDir, FreeSize, TotalSize);
|
||||
flblFree.Caption := Format(lngGetString(clngFreeMsg),[cnvFormatFileSize(FreeSize),cnvFormatFileSize(TotalSize)]);
|
||||
end
|
||||
else
|
||||
//TODO
|
||||
|
|
|
|||
166
uglobs.pas
166
uglobs.pas
|
|
@ -16,7 +16,7 @@ unit uGlobs;
|
|||
|
||||
interface
|
||||
uses
|
||||
Classes, uExts, uColorExt, Graphics, uIni;
|
||||
Classes, uExts, uColorExt, Graphics, IniFiles;
|
||||
const
|
||||
cTopBorder = 23; // px on top is title
|
||||
cLeftBorder = 6; // px on left
|
||||
|
|
@ -59,7 +59,7 @@ var
|
|||
gViewerPos:TRect;
|
||||
gEditorPos:TRect;
|
||||
|
||||
procedure LoadGlobs;
|
||||
function LoadGlobs : Boolean;
|
||||
procedure SaveGlobs;
|
||||
function LoadStringsFromFile(var list:TStringList; const sFileName:String):boolean;
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ const
|
|||
cMaxStringItems=50;
|
||||
|
||||
var
|
||||
gIni:TIni =nil;
|
||||
gIni:TIniFile = nil;
|
||||
|
||||
implementation
|
||||
uses
|
||||
|
|
@ -76,30 +76,30 @@ uses
|
|||
procedure LoadRect(Var ARect:TRect; sPrefix:String);
|
||||
begin
|
||||
// writeln('Load Rect',sPrefix);
|
||||
ARect.Left:=StrToIntDef(gIni.Value[sPrefix+'left'],50);
|
||||
ARect.Left:=gIni.ReadInteger('Configuration', sPrefix+'left',50);
|
||||
// writeln(ARect.Left);
|
||||
ARect.Top:=StrToIntDef(gIni.Value[sPrefix+'top'],50);
|
||||
ARect.Top:=gIni.ReadInteger('Configuration', sPrefix+'top',50);
|
||||
// writeln(ARect.Top);
|
||||
// warning Bottom = height rigth = width, TRect is used only for simplification
|
||||
ARect.Bottom:=StrToIntDef(gIni.Value[sPrefix+'height'],300);
|
||||
ARect.Bottom:=gIni.ReadInteger('Configuration', sPrefix+'height',300);
|
||||
// writeln(ARect.Bottom);
|
||||
ARect.Right:=StrToIntDef(gIni.Value[sPrefix+'width'],400);
|
||||
ARect.Right:=gIni.ReadInteger('Configuration', sPrefix+'width',400);
|
||||
// writeln(ARect.Right);
|
||||
end;
|
||||
|
||||
procedure SaveRect(ARect:TRect; sPrefix:String);
|
||||
begin
|
||||
|
||||
gIni.Value[sPrefix+'left']:=IntToStr(ARect.Left+cLeftBorder);
|
||||
gIni.Value[sPrefix+'top']:=IntToStr(ARect.Top+cTopBorder);
|
||||
gIni.WriteInteger('Configuration', sPrefix+'left', ARect.Left + cLeftBorder);
|
||||
gIni.WriteInteger('Configuration', sPrefix+'top', ARect.Top + cTopBorder);
|
||||
// warning Bottom = height rigth = width, TRect is used only for simplification
|
||||
gIni.Value[sPrefix+'height']:=IntToStr(ARect.Bottom);
|
||||
gIni.Value[sPrefix+'width']:=IntToStr(ARect.Right);
|
||||
gIni.WriteInteger('Configuration', sPrefix+'height', ARect.Bottom);
|
||||
gIni.WriteInteger('Configuration', sPrefix+'width', ARect.Right);
|
||||
end;
|
||||
|
||||
procedure InitGlobs;
|
||||
begin
|
||||
gIni:=TIni.Create(gpIniDir+'doublecmd.ini');
|
||||
gIni:=TIniFile.Create(gpIniDir+'doublecmd.ini');
|
||||
gExts:=TExts.Create;
|
||||
gColorExt:=TColorExt.Create;
|
||||
glsHotDir:=TStringList.Create;
|
||||
|
|
@ -120,71 +120,71 @@ begin
|
|||
FreeAndNil(gIni);
|
||||
end;
|
||||
|
||||
function StrToBoolDef(const sString:String; bDef:Boolean):Boolean;
|
||||
begin
|
||||
if sString='' then
|
||||
Result:=bDef
|
||||
else
|
||||
Result:=StrToBool(sString);
|
||||
end;
|
||||
|
||||
procedure LoadGlobs;
|
||||
function LoadGlobs : Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
writeln('Loading configuration...');
|
||||
InitGlobs;
|
||||
gShowSystemFiles:=StrToBoolDef(gIni.Value['ShowSystemFiles'], False);
|
||||
gLng:=gIni.Value['Language'];
|
||||
gTerm:=gIni.Value['Term'];
|
||||
gCaseSensitiveSort:=StrToBoolDef(gIni.Value['CaseSensitiveSort'], False);
|
||||
gLynxLike:=StrToBoolDef(gIni.Value['LynxLike'], True);
|
||||
gDirSelect:=StrToBoolDef(gIni.Value['DirSelect'], True);
|
||||
glsHotDir.CommaText:=gIni.Value['HotDir'];
|
||||
gShortFileSizeFormat:=StrToBoolDef(gIni.Value['ShortFileSizeFormat'], True);
|
||||
gShowSystemFiles := gIni.ReadBool('Configuration', 'ShowSystemFiles', False);
|
||||
gLng := gIni.ReadString('Configuration', 'Language', gLng);
|
||||
gTerm := gIni.ReadString('Configuration', 'Term', gTerm);
|
||||
gCaseSensitiveSort := gIni.ReadBool('Configuration', 'CaseSensitiveSort', False);
|
||||
gLynxLike := gIni.ReadBool('Configuration', 'LynxLike', True);
|
||||
gDirSelect := gIni.ReadBool('Configuration', 'DirSelect', True);
|
||||
glsHotDir.CommaText := gIni.ReadString('Configuration', 'HotDir', '');
|
||||
gShortFileSizeFormat := gIni.ReadBool('Configuration', 'ShortFileSizeFormat', True);
|
||||
|
||||
gUseExtEdit:=StrToBoolDef(gIni.Value['UseExtEdit'], False);
|
||||
gUseExtView:=StrToBoolDef(gIni.Value['UseExtView'], False);
|
||||
gUseExtDiff:=StrToBoolDef(gIni.Value['UseExtDiff'], False);
|
||||
gSeparateExt:=StrToBoolDef(gIni.Value['SeparateExt'], True);
|
||||
gUseExtEdit := gIni.ReadBool('Configuration', 'UseExtEdit', False);
|
||||
gUseExtView := gIni.ReadBool('Configuration', 'UseExtView', False);
|
||||
gUseExtDiff := gIni.ReadBool('Configuration', 'UseExtDiff', False);
|
||||
gSeparateExt := gIni.ReadBool('Configuration', 'SeparateExt', True);
|
||||
|
||||
gExtEdit:=gIni.Value['ExtEdit'];
|
||||
gExtView:=gIni.Value['ExtView'];
|
||||
gExtDiff:=gIni.Value['ExtDiff'];
|
||||
gRunTerm:=gIni.Value['RunTerm'];
|
||||
gExtEdit := gIni.ReadString('Configuration', 'ExtEdit', '');
|
||||
gExtView := gIni.ReadString('Configuration', 'ExtView', '');
|
||||
gExtDiff := gIni.ReadString('Configuration', 'ExtDiff', '');
|
||||
gRunTerm := gIni.ReadString('Configuration', 'RunTerm', gRunTerm);
|
||||
|
||||
gFontName:=gIni.Value['FontName'];
|
||||
gFontWeight := StrToIntDef(gIni.Value['FontWeight'],700);
|
||||
gFontName:=gIni.ReadString('Configuration', 'FontName', '');
|
||||
gFontWeight := gIni.ReadInteger('Configuration', 'FontWeight', 700);
|
||||
writeln('gFontName:',gFontName);
|
||||
gEditorFontName:=gIni.Value['FontEditorName'];
|
||||
gEditorFontName:=gIni.ReadString('Configuration', 'FontEditorName', '');
|
||||
writeln('gEditorFontName:',gEditorFontName);
|
||||
gViewerFontName:=gIni.Value['FontViewerName'];
|
||||
gViewerFontName:=gIni.ReadString('Configuration', 'FontViewerName', '');
|
||||
writeln('gViewerEditorFontName:',gViewerFontName);
|
||||
gFontSize:=StrToIntDef(gIni.Value['FontSize'],10);
|
||||
gEditorSize:=StrToIntDef(gIni.Value['EditorSize'],14);
|
||||
gViewerSize:=StrToIntDef(gIni.Value['ViewerSize'],14);
|
||||
gFontSize:=gIni.ReadInteger('Configuration', 'FontSize', 10);
|
||||
gEditorSize:=gIni.ReadInteger('Configuration', 'EditorSize', 14);
|
||||
gViewerSize:=gIni.ReadInteger('Configuration', 'ViewerSize', 14);
|
||||
|
||||
if FileExists(gpCfgDir+'doublecmd.ext') then
|
||||
gExts.LoadFromFile(gpCfgDir+'doublecmd.ext');
|
||||
|
||||
gExts.LoadFromFile(gpCfgDir+'doublecmd.ext');
|
||||
LoadStringsFromFile(glsDirHistory,gpIniDir+'dirhistory.txt');
|
||||
gColorExt.LoadFromFile(gpCfgDir+'color.ext');
|
||||
if FileExists(gpIniDir+'dirhistory.txt') then
|
||||
LoadStringsFromFile(glsDirHistory,gpIniDir+'dirhistory.txt');
|
||||
|
||||
if FileExists(gpCfgDir+'color.ext') then
|
||||
gColorExt.LoadFromFile(gpCfgDir+'color.ext');
|
||||
|
||||
// default column widths
|
||||
gColumnSize[0]:=StrToIntDef(gIni.Value['Col0'],133);
|
||||
gColumnSize[1]:=StrToIntDef(gIni.Value['Col1'],50);
|
||||
gColumnSize[2]:=StrToIntDef(gIni.Value['Col2'],64);
|
||||
gColumnSize[3]:=StrToIntDef(gIni.Value['Col3'],73);
|
||||
gColumnSize[4]:=StrToIntDef(gIni.Value['Col4'],59);
|
||||
gColumnSize[0] := gIni.ReadInteger('Configuration', 'Col0', 133);
|
||||
gColumnSize[1] := gIni.ReadInteger('Configuration', 'Col1', 50);
|
||||
gColumnSize[2] := gIni.ReadInteger('Configuration', 'Col2', 64);
|
||||
gColumnSize[3] := gIni.ReadInteger('Configuration', 'Col3', 73);
|
||||
gColumnSize[4] := gIni.ReadInteger('Configuration', 'Col4', 59);
|
||||
|
||||
writeln('Loading viewer position...');
|
||||
LoadRect(gViewerPos, 'Viewer.');
|
||||
writeln('Loading editor position...');
|
||||
LoadRect(gEditorPos, 'Editor.');
|
||||
DoLoadLng;
|
||||
msgLoadLng;
|
||||
end;
|
||||
|
||||
function Bool2Str(b:Boolean):Char;
|
||||
begin
|
||||
Result:=Chr(ord(b)+ord('0'));
|
||||
if FileExists(gpLngDir + gLng) then
|
||||
begin
|
||||
DoLoadLng;
|
||||
msgLoadLng;
|
||||
Result := True;
|
||||
WriteLn
|
||||
end
|
||||
else
|
||||
msgError('File "' + gpLngDir + gLng + '" not found. Double Commander is closed.');
|
||||
end;
|
||||
|
||||
function LoadStringsFromFile(var list:TStringList; const sFileName:String):boolean;
|
||||
|
|
@ -211,42 +211,40 @@ var
|
|||
begin
|
||||
glsDirHistory.SaveToFile(gpIniDir+'dirhistory.txt');
|
||||
|
||||
gIni.Value['ShowSystemFiles']:=Bool2Str(gShowSystemFiles);
|
||||
gIni.Value['Language']:=gLng;
|
||||
gIni.Value['Term']:=gTerm;
|
||||
gIni.Value['CaseSensitiveSort']:=Bool2Str(gCaseSensitiveSort);
|
||||
gIni.Value['LynxLike']:=Bool2Str(gLynxLike);
|
||||
gIni.Value['DirSelect']:=Bool2Str(gDirSelect);
|
||||
gIni.Value['HotDir']:=glsHotDir.CommaText;
|
||||
gIni.Value['ShortFileSizeFormat']:=Bool2Str(gShortFileSizeFormat);
|
||||
gIni.WriteBool('Configuration', 'ShowSystemFiles', gShowSystemFiles);
|
||||
gIni.WriteString('Configuration', 'Language', gLng);
|
||||
gIni.WriteString('Configuration', 'Term', gTerm);
|
||||
gIni.WriteBool('Configuration', 'CaseSensitiveSort', gCaseSensitiveSort);
|
||||
gIni.WriteBool('Configuration', 'LynxLike', gLynxLike);
|
||||
gIni.WriteBool('Configuration', 'DirSelect', gDirSelect);
|
||||
gIni.WriteString('Configuration', 'HotDir', glsHotDir.CommaText);
|
||||
gIni.WriteBool('Configuration', 'ShortFileSizeFormat', gShortFileSizeFormat);
|
||||
|
||||
|
||||
gIni.Value['UseExtEdit']:=Bool2Str(gUseExtEdit);
|
||||
gIni.Value['UseExtView']:=Bool2Str(gUseExtView);
|
||||
gIni.Value['UseExtDiff']:=Bool2Str(gUseExtDiff);
|
||||
gIni.Value['SeparateExt']:=Bool2Str(gSeparateExt);
|
||||
gIni.WriteBool('Configuration', 'UseExtEdit', gUseExtEdit);
|
||||
gIni.WriteBool('Configuration', 'UseExtView', gUseExtView);
|
||||
gIni.WriteBool('Configuration', 'UseExtDiff', gUseExtDiff);
|
||||
gIni.WriteBool('Configuration', 'SeparateExt', gSeparateExt);
|
||||
|
||||
gIni.Value['ExtEdit']:=gExtEdit;
|
||||
gIni.Value['ExtView']:=gExtView;
|
||||
gIni.Value['ExtDiff']:=gExtDiff;
|
||||
gIni.Value['RunTerm']:=gRunTerm;
|
||||
gIni.WriteString('Configuration', 'ExtEdit', gExtEdit);
|
||||
gIni.WriteString('Configuration', 'ExtView', gExtView);
|
||||
gIni.WriteString('Configuration', 'ExtDiff', gExtDiff);
|
||||
gIni.WriteString('Configuration', 'RunTerm', gRunTerm);
|
||||
|
||||
gIni.Value['FontName']:=gFontName;
|
||||
gIni.Value['FontWeight'] := IntToStr(gFontWeight);
|
||||
gIni.Value['FontEditorName']:=gEditorFontName;
|
||||
gIni.Value['FontViewerName']:=gViewerFontName;
|
||||
gIni.WriteString('Configuration', 'FontName', gFontName);
|
||||
gIni.WriteInteger('Configuration', 'FontWeight', gFontWeight);
|
||||
gIni.WriteString('Configuration', 'FontEditorName', gEditorFontName);
|
||||
gIni.WriteString('Configuration', 'FontViewerName', gViewerFontName);
|
||||
|
||||
gIni.Value['FontSize']:=IntToStr(gFontSize);
|
||||
gIni.Value['EditorSize']:=IntToStr(gEditorSize);
|
||||
gIni.Value['ViewerSize']:=IntToStr(gViewerSize);
|
||||
gIni.WriteInteger('Configuration', 'FontSize', gFontSize);
|
||||
gIni.WriteInteger('Configuration', 'EditorSize', gEditorSize);
|
||||
gIni.WriteInteger('Configuration', 'ViewerSize', gViewerSize);
|
||||
|
||||
for x:=0 to 4 do
|
||||
gIni.Value['Col'+IntToStr(x)]:= IntToStr(gColumnSize[x]);
|
||||
gIni.WriteInteger('Configuration', 'Col'+IntToStr(x), gColumnSize[x]);
|
||||
|
||||
SaveRect(gViewerPos, 'Viewer.');
|
||||
SaveRect(gEditorPos, 'Editor.');
|
||||
|
||||
gIni.Save;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
|
|
|||
77
uini.pas
77
uini.pas
|
|
@ -1,77 +0,0 @@
|
|||
{
|
||||
Seksi Commander
|
||||
----------------------------
|
||||
Licence : GNU GPL v 2.0
|
||||
Author : radek.cervinka@centrum.cz
|
||||
|
||||
very simple implementation of ini file
|
||||
|
||||
contributors:
|
||||
|
||||
}
|
||||
|
||||
|
||||
unit uIni;
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes;
|
||||
type
|
||||
TIni=Class
|
||||
private
|
||||
fIniFile:TStringList;
|
||||
fChanged:Boolean;
|
||||
fIniName:String;
|
||||
public
|
||||
Constructor Create(const sIniName:String);
|
||||
Destructor Destroy; override;
|
||||
function GetValue(const sKey:String):String;
|
||||
procedure SetValue(const sKey, sValue:String);
|
||||
procedure Save;
|
||||
property Value[const sKey: string]:String read GetValue write SetValue;
|
||||
end;
|
||||
|
||||
implementation
|
||||
uses
|
||||
SysUtils;
|
||||
Constructor TIni.Create(const sIniName:String);
|
||||
begin
|
||||
fIniFile:=TStringList.Create;
|
||||
fIniName:=ExpandFileName(sIniName);
|
||||
fIniFile.LoadFromFile(sIniName);
|
||||
fChanged:=False;
|
||||
end;
|
||||
|
||||
Destructor TIni.Destroy;
|
||||
begin
|
||||
if assigned(fIniFile) then
|
||||
begin
|
||||
{ try
|
||||
Save;
|
||||
finally}
|
||||
FreeAndNil(fIniFile);
|
||||
// end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TIni.GetValue(const sKey:String):String;
|
||||
begin
|
||||
Result:=fIniFile.Values[sKey];
|
||||
end;
|
||||
|
||||
procedure TIni.SetValue(const sKey, sValue:String);
|
||||
begin
|
||||
if sValue<>GetValue(sKey) then
|
||||
begin
|
||||
fIniFile.Values[sKey]:=sValue;
|
||||
fChanged:=True;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIni.Save;
|
||||
begin
|
||||
if fChanged then fIniFile.SaveToFile(fIniName);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
@ -140,27 +140,30 @@ var
|
|||
png:TPortableNetworkGraphic;
|
||||
|
||||
begin
|
||||
assignFile(f,sFileName);
|
||||
reset(f);
|
||||
try
|
||||
while not eof(f) do
|
||||
begin
|
||||
readln(f,s);
|
||||
s:=Trim(lowercase(s));
|
||||
iekv:=Pos('=',s);
|
||||
if iekv=0 then
|
||||
Continue;
|
||||
sExt:=Copy(s,1, iekv-1);
|
||||
sPixMap:=Copy(s, iekv+1, length(s)-iekv);
|
||||
iPixMap:=CheckAddPixmap(sPixMap);
|
||||
if iPixMap<0 then
|
||||
Continue;
|
||||
if FileExists(sFileName) then
|
||||
begin
|
||||
assignFile(f,sFileName);
|
||||
reset(f);
|
||||
try
|
||||
while not eof(f) do
|
||||
begin
|
||||
readln(f,s);
|
||||
s:=Trim(lowercase(s));
|
||||
iekv:=Pos('=',s);
|
||||
if iekv=0 then
|
||||
Continue;
|
||||
sExt:=Copy(s,1, iekv-1);
|
||||
sPixMap:=Copy(s, iekv+1, length(s)-iekv);
|
||||
iPixMap:=CheckAddPixmap(sPixMap);
|
||||
if iPixMap<0 then
|
||||
Continue;
|
||||
|
||||
if FExtList.IndexOf(sExt)<0 then
|
||||
FExtList.AddObject(sExt, TObject(iPixMap));
|
||||
if FExtList.IndexOf(sExt)<0 then
|
||||
FExtList.AddObject(sExt, TObject(iPixMap));
|
||||
end;
|
||||
finally
|
||||
CloseFile(f);
|
||||
end;
|
||||
finally
|
||||
CloseFile(f);
|
||||
end;
|
||||
// add some standard icons
|
||||
FiDirIconID:=CheckAddPixmap('fdir.png');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue