You've already forked lina-components
mirror of
https://bitbucket.org/Dennis07/lina-components.git
synced 2025-08-24 21:49:04 +02:00
Version 1.0 DEV 1.07
Signed-off-by: Dennis07 <den.goehlert@t-online.de>
This commit is contained in:
@@ -3,7 +3,7 @@ library for Delphi. It is being actively developed by
|
||||
Dennis G�hlert and other voluntary programmers and being improved
|
||||
almost every day.
|
||||
The base release platform is Delphi XE5 on Windows 8.1, but there
|
||||
is also compatibility for older and newer releases od Delphi.
|
||||
is also compatibility for older and newer releases of Delphi.
|
||||
Lazarus is currently not officially supported.
|
||||
|
||||
For more information on Lina Components, such as how to set it up
|
||||
|
@@ -1,4 +1,4 @@
|
||||
These statistics cover the official repository of Lina Components.
|
||||
|
||||
Total lines of code (LoC): 3100+
|
||||
Total lines of code (LoC): 3800+
|
||||
Total visual components (VC): 9
|
@@ -1,6 +1,7 @@
|
||||
package LINA_D_XE5;
|
||||
|
||||
{$R *.res}
|
||||
{$R '..\..\Resource\Compiled\uAdvCtrls.dcr'}
|
||||
{$R '..\..\Resource\Compiled\uBattery.dcr'}
|
||||
{$R '..\..\Resource\Compiled\uFrmCtrls.dcr'}
|
||||
{$R '..\..\Resource\Compiled\uLocalMgr.dcr'}
|
||||
|
@@ -100,6 +100,7 @@
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<DCCReference Include="..\..\Resource\Compiled\uAdvCtrls.dcr"/>
|
||||
<DCCReference Include="..\..\Resource\Compiled\uBattery.dcr"/>
|
||||
<DCCReference Include="..\..\Resource\Compiled\uFrmCtrls.dcr"/>
|
||||
<DCCReference Include="..\..\Resource\Compiled\uLocalMgr.dcr"/>
|
||||
|
@@ -1,39 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<BorlandProject>
|
||||
<Transactions>
|
||||
<Transaction>1899.12.30 00:00:00.000.325,=dbrtl.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.681,C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Resource\Lina.rc=</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.508,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uBase.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.592,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uFileTools.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.675,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.791,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.809,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Resource\Lina.rc</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.325,=dbrtl.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.592,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uFileTools.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.681,C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Resource\Lina.rc=</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.675,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.412,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.411,C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uAdvCtrls.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.582,C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uWebCtrls.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.576,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uSysTools.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.318,=vcl.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.414,C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uLinaTest.pas=</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.556,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uLocalMgr.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.577,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uBattery.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.633,C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\LINA_D_XE5.dproj=C:\Users\Dennis\Documents\RAD Studio\Projekte\Package1.dproj</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.648,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uScriptMgr.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.518,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uBattery.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.621,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uLinaTest.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.414,C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uLinaTest.pas=</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.525,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uCrypt.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.672,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\uFrmCtrls.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.518,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uBattery.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.508,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uBase.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.318,=vcl.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.648,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uScriptMgr.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.196,=rtl.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.525,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uCrypt.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.686,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\uSysTools.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.555,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uBase.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.118,=IndyCore.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.535,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uFileTools.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.672,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\uFrmCtrls.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.633,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uLocalMgr.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.582,C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uWebCtrls.pas=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.555,=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\uBase.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.546,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uFrmCtrls.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.799,=PascalScript_Core_D19.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.566,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uScriptMgr.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.411,C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uAdvCtrls.pas=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.584,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uVirtObj.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.971,=IndySystem.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.546,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uFrmCtrls.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.857,=PascalScript_Core_D19.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.791,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Package\Delphi_XE5\Unit1.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.566,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uScriptMgr.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.633,C:\Users\Dennis\Documents\RAD Studio\Projekte\Package1.dproj=C:\Users\Dennis\Documents\RAD Studio\Projekte\LinaComponents\LINA_D_XE5.dproj</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.584,=C:\Users\Dennis G\Documents\RAD Studio\Projekte\LinaComponents\Source\uVirtObj.pas</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.799,=PascalScript_Core_D19.dcp</Transaction>
|
||||
<Transaction>1899.12.30 00:00:00.000.045,=IndyProtocols.dcp</Transaction>
|
||||
</Transactions>
|
||||
<ProjectSortOrder AutoSort="0" SortType="0">
|
||||
@@ -46,6 +46,7 @@
|
||||
<File Path="..\..\Resource\Compiled\uScriptMgr.dcr"/>
|
||||
<File Path="..\..\Resource\Compiled\uVirtObj.dcr"/>
|
||||
<File Path="..\..\Resource\Compiled\uWebCtrls.dcr"/>
|
||||
<File Path="..\..\Resource\Compiled\uAdvCtrls.dcr"/>
|
||||
<File Path="..\..\Source"/>
|
||||
<File Path="..\..\Source\uAdvCtrls.pas"/>
|
||||
<File Path="..\..\Source\uBase.pas"/>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -8,14 +8,9 @@ unit uFileTools;
|
||||
|
||||
interface
|
||||
|
||||
{ Da Delphi vor Version 2009 noch keine Generics kannte, musste die TWinFiles-
|
||||
Deklaration auf Compiler-Versionen 20.0 oder h�her beschr�nkt werden.
|
||||
Meines Wissens nach gibt es keine einfache M�glichkeit, Typisierte Listen
|
||||
auch in �ltere Versionen zu integrieren. }
|
||||
|
||||
uses
|
||||
{ Standard-Units }
|
||||
Classes, SysUtils, ShellAPI, Forms, Winapi.Windows, Dialogs,
|
||||
Classes, SysUtils, ShellAPI, Forms, Windows, Dialogs,
|
||||
{$IFNDEF NO_GENERIC}
|
||||
Generics.Collections,
|
||||
{$ENDIF}
|
||||
@@ -24,6 +19,7 @@ uses
|
||||
|
||||
type
|
||||
{ Fehlermeldungen }
|
||||
EDriveNoExist = class(Exception);
|
||||
EFileNoExist = class(Exception);
|
||||
EMissingTypeDesc = class(Exception);
|
||||
EMissingExts = class(Exception);
|
||||
@@ -33,36 +29,53 @@ type
|
||||
{ Hilfsklassen }
|
||||
TFileExecuteMode = (feOpen,feEdit,feExplore,feFind,fePrint);
|
||||
TFileNameStyles = set of (fnDirectory,fnExtension);
|
||||
TFileAttributes = set of (faReadOnly,faHidden,faSystem,faArchive,faTemporary);
|
||||
|
||||
type
|
||||
{ Hauptklassen }
|
||||
TWinDrive = class
|
||||
private
|
||||
{ Private-Deklarationen }
|
||||
FDriveChar: Char;
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
constructor Create(ADriveChar: Char);
|
||||
destructor Destroy; override;
|
||||
property DriveChar: Char read FDriveChar;
|
||||
function GetSpaceTotal: Int64;
|
||||
function GetSpaceFree: Int64;
|
||||
end;
|
||||
|
||||
TWinFile = class
|
||||
private
|
||||
{ Private-Deklarationen }
|
||||
FFileName: String;
|
||||
FExecuteMode: TFileExecuteMode;
|
||||
FDrive: TWinDrive;
|
||||
public
|
||||
{ Public-Deklarationen }
|
||||
constructor Create(AFileName: String);
|
||||
destructor Destroy;
|
||||
destructor Destroy; override;
|
||||
property FileName: String read FFileName;
|
||||
property ExecuteMode: TFileExecuteMode read FExecuteMode write FExecuteMode;
|
||||
property Drive: TWinDrive read FDrive write FDrive;
|
||||
function GetExtension(WithDot: Boolean = True): String; //ExtractFileExt()
|
||||
function GetPath: String; //ExtractFilePath()
|
||||
function GetDir: String; //ExtractFileDir()
|
||||
function GetFileName(WithExt: Boolean = True): String; //ExtractFileName()
|
||||
function GetFolderName: String; //ExtractFileFolder()
|
||||
// GetSize: Int64
|
||||
// GetVersion: Extended
|
||||
// GetAttribute: ...
|
||||
function GetSize: Int64; //GetFileSize()
|
||||
// GetVersion: Extended //GetFileVerion()
|
||||
function GetAttributes: TFileAttributes; //GetFileAttributes();
|
||||
// GetOwner: String
|
||||
// GetCreated: TDateTime
|
||||
// GetModified: TDateTime
|
||||
function GetModified: TDateTime; //GetFileModified()
|
||||
function GetCreated: TDateTime; //GetFileCreated()
|
||||
function GetAccessed: TDateTime; //GetFileAccessed()
|
||||
function Execute: Boolean; //ExecuteFile()
|
||||
function SafeExecute: Boolean; //.............
|
||||
end;
|
||||
|
||||
TWinFiles = array of TWinFile;
|
||||
TWinFileArray = array of TWinFile;
|
||||
|
||||
{$IFNDEF NOGENERIC}
|
||||
TWinFileList = TList<TWinFile>;
|
||||
@@ -74,9 +87,17 @@ type
|
||||
InDir: Boolean = False): Boolean;
|
||||
function ExtractFileFolder(FileName: String): String;
|
||||
procedure ListFiles(Dir: String; OutList: TStrings; FileExts: array of String;
|
||||
NameStyles: TFileNameStyles = []); overload;
|
||||
NameStyles: TFileNameStyles = []);
|
||||
procedure ListFolders(Dir: String; OutList: TStrings;
|
||||
NameStyles: TFileNameStyles = []); overload;
|
||||
NameStyles: TFileNameStyles = []);
|
||||
function ExtractDriveChar(const FileName: String): Char;
|
||||
function DriveCharToFileDir(DriveChar: Char): ShortString;
|
||||
function DriveCharToFilePath(DriveChar: Char): ShortString;
|
||||
function GetFileSize(FileName: String): Int64;
|
||||
function GetFileModified(FileName: String): TDateTime;
|
||||
function GetFileCreated(FileName: String): TDateTime;
|
||||
function GetFileAccessed(FileName: String): TDateTime;
|
||||
function GetFileAttributes(FileName: String): TFileAttributes;
|
||||
|
||||
//const
|
||||
{ Dateierweiterungen f�r ListFiles() }
|
||||
@@ -91,8 +112,6 @@ type
|
||||
|
||||
implementation
|
||||
|
||||
{ TWinFile }
|
||||
|
||||
function FEModeToPChar(FEMode: TFileExecuteMode): PChar;
|
||||
begin
|
||||
case FEMode of
|
||||
@@ -212,10 +231,230 @@ begin
|
||||
Result := ExtractFileName(ExtractFileDir(FileName)); //Name d. �bergeord. Ordners
|
||||
end;
|
||||
|
||||
function ExtractDriveChar(const FileName: String): Char;
|
||||
begin
|
||||
Result := FileName[1];
|
||||
if Length(FileName) >= 2 then
|
||||
begin
|
||||
if FileName[2] <> DriveDelim then
|
||||
begin
|
||||
Result := #0;
|
||||
end else
|
||||
begin
|
||||
if Length(FileName) >= 3 then
|
||||
begin
|
||||
if FileName[3] <> PathDelim then
|
||||
begin
|
||||
Result := #0;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function DriveCharToFileDir(DriveChar: Char): ShortString;
|
||||
begin
|
||||
Result := DriveChar + DriveDelim;
|
||||
end;
|
||||
|
||||
function DriveCharToFilePath(DriveChar: Char): ShortString;
|
||||
begin
|
||||
Result := DriveCharToFileDir(DriveChar) + PathDelim;
|
||||
end;
|
||||
|
||||
function FileTimeToDateTime(FileTime: TFileTime): TDateTime;
|
||||
var
|
||||
LocalTime: TFileTime;
|
||||
SysTime: TSystemTime;
|
||||
begin
|
||||
FileTimeToLocalFileTime(FileTime,LocalTime);
|
||||
FileTimeToSystemTime(LocalTime,SysTime);
|
||||
Result := SystemTimeToDateTime(SysTime);
|
||||
end;
|
||||
|
||||
function GetFileSize(FileName: String): Int64;
|
||||
var
|
||||
FileHandle: THandle;
|
||||
FindData: TWIN32FINDDATA;
|
||||
begin
|
||||
Result := -1;
|
||||
if FileExists(FileName) then
|
||||
begin
|
||||
FileHandle := FindFirstFile(pchar(FileName),FindData);
|
||||
if FileHandle = INVALID_HANDLE_VALUE then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
Result := (FindData.nFileSizeHigh * (MAXDWORD)) + FindData.nFileSizeLow;
|
||||
Windows.FindClose(FileHandle);
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetFileModified(FileName: String): TDateTime;
|
||||
var
|
||||
FileHandle: THandle;
|
||||
FindData: TWIN32FINDDATA;
|
||||
begin
|
||||
Result := StrToTime('00.00.0000 00:00:00');
|
||||
if FileExists(FileName) then
|
||||
begin
|
||||
FileHandle := FindFirstFile(PChar(FileName),FindData);
|
||||
if FileHandle = INVALID_HANDLE_VALUE then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
Result := FileTimeToDateTime(FindData.ftLastWriteTime);
|
||||
Windows.FindClose(FileHandle);
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetFileCreated(FileName: String): TDateTime;
|
||||
var
|
||||
FileHandle: THandle;
|
||||
FindData: TWIN32FINDDATA;
|
||||
begin
|
||||
Result := StrToTime('00.00.0000 00:00:00');
|
||||
if FileExists(FileName) then
|
||||
begin
|
||||
FileHandle := FindFirstFile(PChar(FileName),FindData);
|
||||
if FileHandle = INVALID_HANDLE_VALUE then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
Result := FileTimeToDateTime(FindData.ftCreationTime);
|
||||
Windows.FindClose(FileHandle);
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetFileAccessed(FileName: String): TDateTime;
|
||||
var
|
||||
FileHandle: THandle;
|
||||
FindData: TWIN32FINDDATA;
|
||||
begin
|
||||
Result := StrToTime('00.00.0000 00:00:00');
|
||||
if FileExists(FileName) then
|
||||
begin
|
||||
FileHandle := FindFirstFile(PChar(FileName),FindData);
|
||||
if FileHandle = INVALID_HANDLE_VALUE then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
Result := FileTimeToDateTime(FindData.ftLastAccessTime);
|
||||
Windows.FindClose(FileHandle);
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetFileAttributes(FileName: String): TFileAttributes;
|
||||
var
|
||||
FileHandle: THandle;
|
||||
FindData: TWIN32FINDDATA;
|
||||
begin
|
||||
Result := [];
|
||||
if FileExists(FileName) then
|
||||
begin
|
||||
FileHandle := FindFirstFile(PChar(FileName),FindData);
|
||||
if FileHandle = INVALID_HANDLE_VALUE then
|
||||
begin
|
||||
Exit;
|
||||
end;
|
||||
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_READONLY) = FILE_ATTRIBUTE_READONLY then
|
||||
begin
|
||||
Result := Result + [faReadOnly];
|
||||
end;
|
||||
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_HIDDEN) = FILE_ATTRIBUTE_HIDDEN then
|
||||
begin
|
||||
Result := Result + [faHidden];
|
||||
end;
|
||||
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_SYSTEM) = FILE_ATTRIBUTE_SYSTEM then
|
||||
begin
|
||||
Result := Result + [faSystem];
|
||||
end;
|
||||
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_ARCHIVE) = FILE_ATTRIBUTE_ARCHIVE then
|
||||
begin
|
||||
Result := Result + [faArchive];
|
||||
end;
|
||||
if (FindData.dwFileAttributes and FILE_ATTRIBUTE_TEMPORARY) = FILE_ATTRIBUTE_TEMPORARY then
|
||||
begin
|
||||
Result := Result + [faTemporary];
|
||||
end;
|
||||
Windows.FindClose(FileHandle);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ ----------------------------------------------------------------------------
|
||||
TWinDrive
|
||||
---------------------------------------------------------------------------- }
|
||||
|
||||
constructor TWinDrive.Create(ADriveChar: Char);
|
||||
begin
|
||||
FDriveChar := ADriveChar;
|
||||
if DirectoryExists(ADriveChar) = False then
|
||||
begin
|
||||
raise EDriveNoExist.Create('Drive not found: "' + DriveChar + '"');
|
||||
end;
|
||||
end;
|
||||
|
||||
destructor TWinDrive.Destroy;
|
||||
begin
|
||||
//...
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TWinDrive.GetSpaceTotal: Int64;
|
||||
var
|
||||
RootChars: array[0..4] of Char;
|
||||
Root: PChar;
|
||||
Dir: String;
|
||||
Buffer: Int64;
|
||||
begin
|
||||
RootChars[0] := FDriveChar;
|
||||
RootChars[1] := DriveDelim;
|
||||
RootChars[2] := PathDelim;
|
||||
RootChars[3] := #0;
|
||||
Root := RootChars;
|
||||
Dir := GetCurrentDir;
|
||||
if SetCurrentDir(DriveCharToFilePath(FDriveChar)) then
|
||||
begin
|
||||
GetDiskFreeSpaceEx(Root,Buffer,Result,nil);
|
||||
SetCurrentDir(Dir);
|
||||
end else
|
||||
begin
|
||||
Result := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TWinDrive.GetSpaceFree: Int64;
|
||||
var
|
||||
RootChars: array[0..4] of Char;
|
||||
Root: PChar;
|
||||
Dir: String;
|
||||
Buffer: Int64;
|
||||
begin
|
||||
RootChars[0] := FDriveChar;
|
||||
RootChars[1] := DriveDelim;
|
||||
RootChars[2] := PathDelim;
|
||||
RootChars[3] := #0;
|
||||
Root := RootChars;
|
||||
Dir := GetCurrentDir;
|
||||
if SetCurrentDir(DriveCharToFilePath(FDriveChar)) then
|
||||
begin
|
||||
GetDiskFreeSpaceEx(Root,Result,Buffer,nil);
|
||||
SetCurrentDir(Dir);
|
||||
end else
|
||||
begin
|
||||
Result := -1;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ ----------------------------------------------------------------------------
|
||||
TWinFile
|
||||
---------------------------------------------------------------------------- }
|
||||
|
||||
constructor TWinFile.Create(AFileName: String);
|
||||
begin
|
||||
ExecuteMode := feOpen;
|
||||
FFileName := AFileName;
|
||||
Drive := TWinDrive.Create(ExtractDriveChar(FFileName));
|
||||
if FileExists(AFileName) = False then
|
||||
begin
|
||||
raise EFileNoExist.Create('File not found: "' + AFileName + '"');
|
||||
@@ -224,7 +463,8 @@ end;
|
||||
|
||||
destructor TWinFile.Destroy;
|
||||
begin
|
||||
ExecuteMode := feOpen;
|
||||
Drive.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TWinFile.GetExtension(WithDot: Boolean = True): String;
|
||||
@@ -254,6 +494,11 @@ begin
|
||||
Result := ExtractFileFolder(FFileName);
|
||||
end;
|
||||
|
||||
function TWinFile.GetSize: Int64;
|
||||
begin
|
||||
Result := GetFileSize(FFileName);
|
||||
end;
|
||||
|
||||
function TWinFile.GetPath: String;
|
||||
begin
|
||||
Result := ExtractFilePath(FFileName); //Gesamter Ordnerpfad (ohne Dateiname)
|
||||
@@ -264,14 +509,34 @@ begin
|
||||
Result := ExtractFileDir(FFileName);
|
||||
end;
|
||||
|
||||
function TWinFile.GetModified: TDateTime;
|
||||
begin
|
||||
Result := GetFileModified(FFileName);
|
||||
end;
|
||||
|
||||
function TWinFile.GetCreated: TDateTime;
|
||||
begin
|
||||
Result := GetFileCreated(FFileName);
|
||||
end;
|
||||
|
||||
function TWinFile.GetAccessed: TDateTime;
|
||||
begin
|
||||
Result := GetFileAccessed(FFileName);
|
||||
end;
|
||||
|
||||
function TWinFile.GetAttributes: TFileAttributes;
|
||||
begin
|
||||
Result := GetFileAttributes(FFileName);
|
||||
end;
|
||||
|
||||
function TWinFile.Execute: Boolean;
|
||||
begin
|
||||
Result := ExecuteFile(FileName,ExecuteMode);
|
||||
Result := ExecuteFile(FFileName,ExecuteMode);
|
||||
end;
|
||||
|
||||
function TWinFile.SafeExecute: Boolean;
|
||||
begin
|
||||
Result := ExecuteFile(FileName,ExecuteMode,True);
|
||||
Result := ExecuteFile(FFileName,ExecuteMode,True);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Reference in New Issue
Block a user