Skip to content

Commit bc75690

Browse files
committed
Added a more helpful label to the text area for exclusion of folders when persisting the RAM-disk on shutdown.
Replaced the suspicious word "SkypeLog" for the assembly name in the manifest which was a left-over from some copy/pasting from another project in the past. Removed the unused function SplitPath from RamSync.pas Fixed a bug in function SaveSettings which can throw access violation on empty lines in the list of exclusion folders when persisting the RAM-disk on shutdown (thanks to SkybuckFlying for pointing out the bug) Added functions WidePosEx and WStrDelete which are missing from the free TntUnicode package (only present in TMS Unicode)
1 parent a4de57e commit bc75690

File tree

6 files changed

+68
-17
lines changed

6 files changed

+68
-17
lines changed

Main.dfm

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,29 @@ object frmUI: TfrmUI
108108
OnClick = chkSyncClick
109109
end
110110
object grpSync: TGroupBox
111-
Left = 16
112-
Top = 220
113-
Width = 269
114-
Height = 169
115-
Caption = ' Do not persist these folders (no wildcards) '
111+
Left = 12
112+
Top = 212
113+
Width = 274
114+
Height = 177
115+
Caption = ' Do not persist these folders '
116116
Enabled = False
117117
TabOrder = 8
118+
object txtExcludeHelp: TLabel
119+
Left = 6
120+
Top = 18
121+
Width = 260
122+
Height = 13
123+
Caption = 'No nesting - only root folders and no wildcards'
124+
Font.Charset = DEFAULT_CHARSET
125+
Font.Color = clWindowText
126+
Font.Height = -11
127+
Font.Name = 'Tahoma'
128+
Font.Style = [fsBold]
129+
ParentFont = False
130+
end
118131
object chkDelete: TCheckBox
119132
Left = 8
120-
Top = 24
133+
Top = 40
121134
Width = 249
122135
Height = 17
123136
Hint =
@@ -130,9 +143,9 @@ object frmUI: TfrmUI
130143
end
131144
object memoIgnore: TTntMemo
132145
Left = 2
133-
Top = 52
134-
Width = 265
135-
Height = 115
146+
Top = 68
147+
Width = 270
148+
Height = 107
136149
Hint =
137150
'One folder per line,'#13#10'no wildcards, no subfolders,'#13#10'no drive let' +
138151
'ter - folders are'#13#10'relative to the root of RAM-disk'

Main.pas

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ TfrmUI = class(TForm)
3030
memoIgnore: TTntMemo;
3131
btnInstall: TButton;
3232
btnUninstall: TButton;
33+
txtExcludeHelp: TLabel;
3334
procedure btnApplyClick(Sender: TObject);
3435
procedure btnInstallClick(Sender: TObject);
3536
procedure btnLoadClick(Sender: TObject);
@@ -58,14 +59,51 @@ implementation
5859

5960
{$R *.dfm}
6061

61-
Uses Definitions,RamDetect,RamRemove,RamCreate,Types,StrUtils,WinSvc,TntRegistry,TntFileCtrl,TntSysUtils;
62+
Uses Definitions,RamDetect,RamRemove,RamCreate,Types,StrUtils,WinSvc,TntRegistry,TntFileCtrl,TntWideStrUtils;
6263

6364
const
6465
serviceName = 'ArsenalRamDisk';
6566

6667
Var
6768
ramDiskConfig: TRamDisk;
6869

70+
procedure WStrDelete(var S: WideString; Index, Count: Integer);
71+
var
72+
L, N: Integer;
73+
NewStr: PWideChar;
74+
begin
75+
L := Length(S);
76+
if (L > 0) and (Index >= 1) and (Index <= L) and (Count > 0) then
77+
begin
78+
Dec(Index);
79+
N := L - Index - Count;
80+
if N < 0 then N := 0;
81+
if (Index = 0) and (N = 0) then NewStr := nil else
82+
begin
83+
NewStr := WStrAlloc(Index + N);
84+
if Index > 0 then
85+
Move(Pointer(S)^, NewStr^, Index * 2);
86+
if N > 0 then
87+
Move(PWideChar(Pointer(S))[L - N], NewStr[Index], N * 2);
88+
end;
89+
S := WStrPas(NewStr);
90+
WStrDispose(NewStr);
91+
end;
92+
end;
93+
94+
function WidePosEx(const SubStr, S: widestring; Offset: Integer = 1): Integer;
95+
var
96+
i: integer;
97+
tmp: widestring;
98+
begin
99+
Result := 0;
100+
tmp := S;
101+
WStrDelete(tmp,1,Offset);
102+
i := Pos(SubStr, tmp);
103+
if (i > 0) then
104+
Result := Offset + i;
105+
end;
106+
69107
procedure TfrmUI.btnApplyClick(Sender: TObject);
70108
var
71109
msg:String;
@@ -228,7 +266,7 @@ procedure TfrmUI.FormCreate(Sender: TObject);
228266
while i<memoIgnore.Lines.Count Do
229267
Begin
230268
s:=Trim(memoIgnore.Lines[i]);
231-
If s[2]=':' then s:=Copy(s,4,MaxInt);
269+
If (Length(s) >= 2) And (s[2]=':') then s:=Copy(s,4,MaxInt);
232270
If (s='')or(WidePosEx('\',s)>0)or(WidePosEx('/',s)>0) then memoIgnore.Lines.Delete(i)
233271
else
234272
Begin

RamService.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
22
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
3-
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="SkypeLog" type="win32"/>
3+
<assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="RamdiskService" type="win32"/>
44
<description>Arsenal RAM-disk service</description>
55
<!-- Identify the application security requirements. -->
66
<ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft-com:asm.v2">

RamSync.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ procedure TreeDelete(const src,dest:WideString;excluded:TTntStringList);
294294
Until WideFindNext(SR) <> 0;
295295
WideFindClose(SR);
296296
end;
297-
297+
{
298298
Procedure SplitPath(const path:WideString;var list:TStrArray);
299299
var
300300
oldPos,newPos,k:Integer;
@@ -307,14 +307,14 @@ procedure TreeDelete(const src,dest:WideString;excluded:TTntStringList);
307307
if newPos=0 then list[k]:=Copy(path,oldPos,MaxInt)
308308
Else
309309
Begin
310-
list[k]:=Copy(path,oldPos,newPos);
310+
list[k]:=Copy(path,oldPos,newPos - oldPos);
311311
oldPos:=newPos;
312312
end;
313313
Inc(k);
314314
Until newPos=0;
315315
SetLength(list,k);
316316
end;
317-
317+
}
318318
Procedure SaveRamDisk(Var existing:TRamDisk);
319319
var
320320
list:TTntStringList;

RamdiskUI.dof

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ AutoIncBuild=0
115115
MajorVer=1
116116
MinorVer=1
117117
Release=1
118-
Build=2
118+
Build=9
119119
Debug=0
120120
PreRelease=0
121121
Special=0
@@ -126,7 +126,7 @@ CodePage=1251
126126
[Version Info Keys]
127127
CompanyName=
128128
FileDescription=
129-
FileVersion=1.1.1.2
129+
FileVersion=1.1.1.9
130130
InternalName=
131131
LegalCopyright=
132132
LegalTrademarks=

RamdiskUI.res

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)