Skip to content

Commit 30820fa

Browse files
author
delphidabbler
committed
Merge branch 'feature/csdb-v4' into develop
2 parents ac5ed3c + b572c10 commit 30820fa

File tree

662 files changed

+24229
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

662 files changed

+24229
-0
lines changed

csdb/v4.16/collection/001.dat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function WinFileTimeToDOSFileTime(FT: Windows.TFileTime): Integer;
2+
begin
3+
SysUtils.Win32Check(
4+
Windows.FileTimeToDosDateTime(
5+
FT, SysUtils.LongRec(Result).Hi, SysUtils.LongRec(Result).Lo
6+
)
7+
);
8+
end;

csdb/v4.16/collection/002.dat

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function WinFileTimeToDateTime(FT: Windows.TFileTime): TDateTime;
2+
var
3+
SysTime: Windows.TSystemTime; // stores date/time in system time format
4+
begin
5+
// Convert file time to system time, raising exception on error
6+
SysUtils.Win32Check(Windows.FileTimeToSystemTime(FT, SysTime));
7+
// Convert system time to Delphi date time, raising excpetion on error
8+
Result := SysUtils.SystemTimeToDateTime(SysTime);
9+
end;

csdb/v4.16/collection/003.dat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function WinFileTimeToStr(FT: Windows.TFileTime): string;
2+
begin
3+
Result := SysUtils.DateTimeToStr(WinFileTimeToDateTime(FT));
4+
end;

csdb/v4.16/collection/004.dat

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function ParseDelims(const TextLine: string; var StartPos: Integer;
2+
const Delims: string): string;
3+
var
4+
StringEnd: Integer; // tracks end of current string being parsed out
5+
begin
6+
// Find next non-delimiter char - this is where token starts
7+
while (StartPos <= Length(TextLine))
8+
and SysUtils.IsDelimiter(Delims, TextLine, StartPos) do
9+
Inc(StartPos);
10+
// Now find next delimiter - this is where token ends
11+
StringEnd := StartPos;
12+
while (StringEnd <= Length(TextLine))
13+
and not SysUtils.IsDelimiter(Delims, TextLine, StringEnd) do
14+
Inc(StringEnd);
15+
// Copy result out of string
16+
Result := Copy(TextLine, StartPos, StringEnd - StartPos);
17+
StartPos := StringEnd + 1;
18+
end;

csdb/v4.16/collection/005.dat

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
procedure CreateURLShortcut(const ShortcutFile, URL: string);
2+
var
3+
F: TextFile; // text file
4+
begin
5+
{$I+} // ensure file i/o raises exception on error
6+
// Open new file for writing (overwrites any existing file)
7+
AssignFile(F, ShortcutFile);
8+
Rewrite(F);
9+
try
10+
// Write file contents: this is simplest basic format of shortcut file
11+
WriteLn(F, '[InternetShortcut]');
12+
WriteLn(F, 'URL=', URL);
13+
finally
14+
// Close file
15+
CloseFile(F);
16+
end;
17+
end;

csdb/v4.16/collection/006.dat

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function DeleteFileWithUndo(const FileName: string): Boolean;
2+
var
3+
FOS: ShellAPI.TSHFileOpStruct; // contains info about required file operation
4+
begin
5+
// Set up structure that determines file operation
6+
FillChar(FOS, SizeOf(FOS), 0);
7+
with FOS do
8+
begin
9+
wFunc := ShellAPI.FO_DELETE; // we're deleting
10+
pFrom := PChar(FileName + #0); // this file (#0#0 terminated)
11+
fFlags := ShellAPI.FOF_ALLOWUNDO // with facility to undo op
12+
or ShellAPI.FOF_NOCONFIRMATION // and we don't want any dialogs
13+
or ShellAPI.FOF_SILENT;
14+
end;
15+
// Perform the operation
16+
Result := ShellAPI.SHFileOperation(FOS) = 0;
17+
end;

csdb/v4.16/collection/007.dat

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function IsDirectory(const DirName: string): Boolean;
2+
var
3+
Attr: Integer; // directory's file attributes
4+
begin
5+
Attr := SysUtils.FileGetAttr(DirName);
6+
Result := (Attr <> -1) and IsFlagSet(Attr, SysUtils.faDirectory);
7+
end;

csdb/v4.16/collection/008.dat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function DOSToUnixPath(const PathName: string): string;
2+
begin
3+
Result := SysUtils.StringReplace(PathName, '\', '/', [SysUtils.rfReplaceAll]);
4+
end;

csdb/v4.16/collection/009.dat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function GetFileDate(const FName: string): Integer;
2+
var
3+
FileH: Integer; // file handle
4+
begin
5+
// Open file
6+
FileH := SysUtils.FileOpen(FName, SysUtils.fmOpenRead);
7+
if FileH = -1 then
8+
// Couldn't open file - return -1 to indicate can't get date
9+
Result := -1
10+
else
11+
begin
12+
// File opened OK - record date and close file
13+
Result := SysUtils.FileGetDate(FileH);
14+
SysUtils.FileClose(FileH);
15+
end;
16+
end;

csdb/v4.16/collection/010.dat

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
function GetFixedFileVerInfo(const FileName: string;
2+
out FFI: Windows.TVSFixedFileInfo): Boolean;
3+
var
4+
VerInfoBuf: Pointer; // points to memory storing version info
5+
VerInfoSize: Integer; // size of version info memory
6+
Dummy: Cardinal; // unused parameter required by API function
7+
PFFI: Pointer; // points to fixed file info
8+
FFISize: Windows.UINT; // size of file file info returned from API (unused)
9+
begin
10+
// Assume failure: sets zero result
11+
FillChar(FFI, SizeOf(FFI), 0);
12+
Result := False;
13+
// Get size of version info: there is none if this is zero
14+
VerInfoSize := Windows.GetFileVersionInfoSize(PChar(FileName), Dummy);
15+
if VerInfoSize > 0 then
16+
begin
17+
// Allocate memory to store ver info
18+
GetMem(VerInfoBuf, VerInfoSize);
19+
try
20+
// Get the version info, filling buffer
21+
if Windows.GetFileVersionInfo(
22+
PChar(FileName), Dummy, VerInfoSize, VerInfoBuf
23+
) then
24+
begin
25+
// Get a pointer to fixed file info
26+
if Windows.VerQueryValue(VerInfoBuf, '\', PFFI, FFISize) then
27+
begin
28+
// Got pointer OK: record file version
29+
FFI := Windows.PVSFixedFileInfo(PFFI)^;
30+
Result := True;
31+
end;
32+
end;
33+
finally
34+
// Dispose of ver info storage
35+
FreeMem(VerInfoBuf, VerInfoSize);
36+
end;
37+
end;
38+
end;

0 commit comments

Comments
 (0)