Initial
Исходный код версии 2.0
This commit is contained in:
26
sources/cdejecter_dll/data/__history/lEjectCD_core.inc;1
Normal file
26
sources/cdejecter_dll/data/__history/lEjectCD_core.inc;1
Normal file
@@ -0,0 +1,26 @@
|
||||
Result:= False;
|
||||
if ADisc = '' then
|
||||
Abort;
|
||||
S:= ADisc + ':';
|
||||
if GetDriveType(PChar(S)) = DRIVE_CDROM then
|
||||
begin
|
||||
Flags:= mci_Open_Type or mci_Open_Element;
|
||||
with OpenParm do
|
||||
begin
|
||||
dwCallback:= 0;
|
||||
lpstrDeviceType:= 'CDAudio';
|
||||
lpstrElementName:= PChar(S);
|
||||
end;
|
||||
Res:= mciSendCommand(0, mci_Open, Flags, Longint(@OpenParm));
|
||||
if Res <> 0 then
|
||||
Exit;
|
||||
DeviceID:= OpenParm.wDeviceID;
|
||||
try
|
||||
Res:= mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0);
|
||||
if Res = 0 then
|
||||
Exit;
|
||||
Result:= True;
|
||||
finally
|
||||
mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm));
|
||||
end;
|
||||
end;
|
5
sources/cdejecter_dll/data/__history/lEjectCD_vars.inc;1
Normal file
5
sources/cdejecter_dll/data/__history/lEjectCD_vars.inc;1
Normal file
@@ -0,0 +1,5 @@
|
||||
var Res: MciError;
|
||||
OpenParm: TMCI_Open_Parms;
|
||||
Flags: DWord;
|
||||
S: String;
|
||||
DeviceID: Word;
|
11
sources/cdejecter_dll/data/__history/lGetCDDiscs_core.inc;1
Normal file
11
sources/cdejecter_dll/data/__history/lGetCDDiscs_core.inc;1
Normal file
@@ -0,0 +1,11 @@
|
||||
Result:= '';
|
||||
DL:= TDrivesList.Create;
|
||||
SL:= TStringListUTF8.Create;
|
||||
if DL.Count > 0 then
|
||||
for Ind:= 0 to DL.Count - 1 do
|
||||
if DL.Items[Ind].DriveType = dtOptical then
|
||||
SL.Add(DL.Items[Ind].DriveLabel[1]);
|
||||
SL.Delimiter:= ';';
|
||||
Result:= SL.DelimitedText;
|
||||
FreeAndNil(SL);
|
||||
FreeAndNil(DL);
|
@@ -0,0 +1,17 @@
|
||||
s:= ADisc + ':\';
|
||||
root:= PChar(s);
|
||||
GetMem(VolumeNameBuffer, 256);
|
||||
Getmem(FileSystemNameBuffer, 256);
|
||||
VolumeNameSize:= 255;
|
||||
FileSystemNameSize:= 255;
|
||||
res:= GetVolumeInformation(Root, VolumeNameBuffer, VolumeNameSize, @VolumeSerialNumber, MaximumComponentLength, FileSystemFlags, FileSystemNameBuffer, FileSystemNameSize);
|
||||
with Result do
|
||||
begin
|
||||
diHasInfo:= res;
|
||||
diDrive:= ADisc;
|
||||
diVolumeName:= VolumeNameBuffer;
|
||||
diFileSystem:= FileSystemNameBuffer;
|
||||
diSerial:= VolumeSerialNumber;
|
||||
end;
|
||||
Freemem(VolumeNameBuffer, 256);
|
||||
Freemem(FileSystemNameBuffer, 256);
|
@@ -0,0 +1,2 @@
|
||||
DL:= TDrivesList.Create;
|
||||
|
@@ -0,0 +1,6 @@
|
||||
var root: PChar;
|
||||
res: LongBool;
|
||||
VolumeNameBuffer, FileSystemNameBuffer: PChar;
|
||||
VolumeNameSize,FileSystemNameSize: DWORD;
|
||||
VolumeSerialNumber, MaximumComponentLength, FileSystemFlags: DWORD;
|
||||
s: String;
|
@@ -0,0 +1 @@
|
||||
var DL: TDrivesList;
|
@@ -0,0 +1,3 @@
|
||||
var i, j : Integer;
|
||||
Buf : array [0..95] of Char;
|
||||
SL: TStringListUTF8;
|
161
sources/cdejecter_dll/data/double_commander/udrive.pas
Normal file
161
sources/cdejecter_dll/data/double_commander/udrive.pas
Normal file
@@ -0,0 +1,161 @@
|
||||
{
|
||||
Double Commander
|
||||
-------------------------------------------------------------------------
|
||||
Structures describing drives.
|
||||
|
||||
Copyright (C) 2006-2010 Koblov Alexander (Alexx2000@mail.ru)
|
||||
Copyright (C) 2010 Przemyslaw Nagay (cobines@gmail.com)
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
}
|
||||
|
||||
unit uDrive;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes;
|
||||
|
||||
type
|
||||
TDriveType = (dtUnknown,
|
||||
dtFlash, // Flash drive
|
||||
dtFloppy, // 3.5'', ZIP drive, etc.
|
||||
dtHardDisk, // Hard disk drive
|
||||
dtNetwork, // Network share
|
||||
dtOptical, // CD, DVD, Blu-Ray, etc.
|
||||
dtRamDisk, // Ram-disk
|
||||
dtRemovable, // Drive with removable media
|
||||
dtRemovableUsb, // Drive connected via USB
|
||||
dtVirtual, // Virtual drive
|
||||
dtSpecial); // Special drive
|
||||
|
||||
{ TDrive }
|
||||
|
||||
// On Linux we also put here mount points other than drives.
|
||||
|
||||
TDrive = record
|
||||
DisplayName, //<en Name displayed to the user.
|
||||
Path, //<en Where this drive is or should be mounted (by /etc/fstab).
|
||||
DriveLabel, //<en Drive label if filesystem on the drive supports it.
|
||||
DeviceId: String; //<en Device ID that can be used for mounting, ejecting, etc.
|
||||
DriveType : TDriveType;
|
||||
FileSystem: String; //<en Filesystem on the drive
|
||||
IsMediaAvailable: Boolean; //<en Is media available in a drive with removable media.
|
||||
IsMediaEjectable: Boolean; //<en Can eject media by a command.
|
||||
IsMediaRemovable: Boolean; //<en If the drive has removable media.
|
||||
IsMounted: Boolean; //<en Is the drive mounted.
|
||||
AutoMount: Boolean; //<en Should the drive be automounted
|
||||
end;
|
||||
PDrive = ^TDrive;
|
||||
|
||||
{ TDrivesList }
|
||||
|
||||
TDrivesList = class
|
||||
private
|
||||
FList: TFPList;
|
||||
protected
|
||||
function Get(Index: Integer): PDrive;
|
||||
function GetCount: Integer;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
function Add(ADrive: PDrive): Integer;
|
||||
procedure Remove(Index: Integer);
|
||||
procedure RemoveAll;
|
||||
procedure Sort(Compare: TListSortCompare);
|
||||
property Items[Index: Integer]: PDrive read Get; default;
|
||||
property Count: Integer read GetCount;
|
||||
end;
|
||||
|
||||
{en
|
||||
Returns drive label or status description.
|
||||
}
|
||||
function GetDriveLabelOrStatus(Drive: PDrive): String;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
SysUtils;
|
||||
|
||||
function GetDriveLabelOrStatus(Drive: PDrive): String;
|
||||
begin
|
||||
if Drive^.DriveLabel <> EmptyStr then
|
||||
Result := Drive^.DriveLabel
|
||||
else if not Drive^.IsMediaAvailable then
|
||||
Result := 'No media'
|
||||
else
|
||||
Result := 'No label';
|
||||
end;
|
||||
|
||||
{ TDrivesList }
|
||||
|
||||
constructor TDrivesList.Create;
|
||||
begin
|
||||
FList := TFPList.Create;
|
||||
end;
|
||||
|
||||
destructor TDrivesList.Destroy;
|
||||
begin
|
||||
inherited Destroy;
|
||||
RemoveAll;
|
||||
FList.Free;
|
||||
end;
|
||||
|
||||
function TDrivesList.Add(ADrive: PDrive): Integer;
|
||||
begin
|
||||
Result := FList.Add(ADrive);
|
||||
end;
|
||||
|
||||
procedure TDrivesList.Remove(Index: Integer);
|
||||
begin
|
||||
if (Index >= 0) and (Index < FList.Count) then
|
||||
begin
|
||||
Dispose(PDrive(FList[Index]));
|
||||
FList.Delete(Index);
|
||||
end
|
||||
else
|
||||
raise ERangeError.Create('Invalid index');
|
||||
end;
|
||||
|
||||
procedure TDrivesList.RemoveAll;
|
||||
begin
|
||||
while FList.Count > 0 do
|
||||
Remove(0);
|
||||
end;
|
||||
|
||||
procedure TDrivesList.Sort(Compare: TListSortCompare);
|
||||
begin
|
||||
FList.Sort(Compare);
|
||||
end;
|
||||
|
||||
function TDrivesList.Get(Index: Integer): PDrive;
|
||||
begin
|
||||
if (Index >= 0) and (Index < FList.Count) then
|
||||
begin
|
||||
Result := PDrive(FList.Items[Index]);
|
||||
end
|
||||
else
|
||||
raise ERangeError.Create('Invalid index');
|
||||
end;
|
||||
|
||||
function TDrivesList.GetCount: Integer;
|
||||
begin
|
||||
Result := FList.Count;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
37
sources/cdejecter_dll/data/double_commander/umyunix.pas
Normal file
37
sources/cdejecter_dll/data/double_commander/umyunix.pas
Normal file
@@ -0,0 +1,37 @@
|
||||
unit uMyUnix;
|
||||
{$mode objfpc}{$H+}
|
||||
{$packrecords c}
|
||||
|
||||
{$IF NOT DEFINED(LINUX)}
|
||||
{$DEFINE FPC_USE_LIBC}
|
||||
{$ENDIF}
|
||||
interface
|
||||
uses
|
||||
Classes, SysUtils, BaseUnix, CTypes, uDrive;
|
||||
function fpSystemStatus(Command: string): cint;
|
||||
function EjectDrive(Drive: PDrive): Boolean;
|
||||
implementation
|
||||
|
||||
uses
|
||||
URIParser, Unix, Process, LazUTF8
|
||||
{$IF (NOT DEFINED(FPC_USE_LIBC)) or (DEFINED(BSD) AND NOT DEFINED(DARWIN))}
|
||||
, SysCall
|
||||
{$ENDIF}
|
||||
;
|
||||
|
||||
function fpSystemStatus(Command: string): cint;
|
||||
begin
|
||||
Result := fpSystem(UTF8ToSys(Command));
|
||||
if wifexited(Result) then
|
||||
Result := wexitStatus(Result);
|
||||
end;
|
||||
|
||||
function EjectDrive(Drive: PDrive): Boolean;
|
||||
begin
|
||||
{$IF DEFINED(DARWIN)}
|
||||
Result := fpSystemStatus('diskutil eject ' + Drive^.DeviceId) = 0;
|
||||
if not Result then
|
||||
{$ENDIF}
|
||||
Result := fpSystemStatus('eject ' + Drive^.DeviceId) = 0;
|
||||
end;
|
||||
end.
|
6
sources/cdejecter_dll/data/lEjectCD_core.inc
Normal file
6
sources/cdejecter_dll/data/lEjectCD_core.inc
Normal file
@@ -0,0 +1,6 @@
|
||||
DL:= TDrivesList.Create;
|
||||
if DL.Count > 0 then
|
||||
for Ind:= 0 to DL.Count - 1 do
|
||||
if (DL.Items[Ind].DriveType = dtOptical) and (DL.Items[Ind].DriveLabel[1] = ADisc) then
|
||||
EjectDrive(DL.Items[Ind]);
|
||||
FreeAndNil(DL);
|
2
sources/cdejecter_dll/data/lEjectCD_vars.inc
Normal file
2
sources/cdejecter_dll/data/lEjectCD_vars.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
var DL: TDrivesList;
|
||||
Ind: Byte;
|
11
sources/cdejecter_dll/data/lGetCDDiscs_core.inc
Normal file
11
sources/cdejecter_dll/data/lGetCDDiscs_core.inc
Normal file
@@ -0,0 +1,11 @@
|
||||
Result:= '';
|
||||
DL:= TDrivesList.Create;
|
||||
SL:= TStringListUTF8.Create;
|
||||
if DL.Count > 0 then
|
||||
for Ind:= 0 to DL.Count - 1 do
|
||||
if DL.Items[Ind].DriveType = dtOptical then
|
||||
SL.Add(DL.Items[Ind].DriveLabel[1]);
|
||||
SL.Delimiter:= ';';
|
||||
Result:= PWideChar(SL.DelimitedText);
|
||||
FreeAndNil(SL);
|
||||
FreeAndNil(DL);
|
3
sources/cdejecter_dll/data/lGetCDDiscs_vars.inc
Normal file
3
sources/cdejecter_dll/data/lGetCDDiscs_vars.inc
Normal file
@@ -0,0 +1,3 @@
|
||||
var DL: TDrivesList;
|
||||
SL: TStringListUTF8;
|
||||
Ind: Byte;
|
13
sources/cdejecter_dll/data/lGetVolumeInfo_core.inc
Normal file
13
sources/cdejecter_dll/data/lGetVolumeInfo_core.inc
Normal file
@@ -0,0 +1,13 @@
|
||||
DL:= TDrivesList.Create;
|
||||
if DL.Count > 0 then
|
||||
for Ind:= 0 to DL.Count - 1 do
|
||||
if (DL.Items[Ind].DriveType = dtOptical) and (DL.Items[Ind].DriveLabel[1] = ADisc) then
|
||||
with Result do
|
||||
begin
|
||||
diHasInfo:= DL.Items[Ind].IsMediaAvailable;
|
||||
diDrive:= DL.Items[Ind].DriveLabel[1];
|
||||
diVolumeName:= DL.Items[Ind].DisplayName;
|
||||
diFileSystem:= DL.Items[Ind].FileSystem;
|
||||
diSerial:= 0;
|
||||
end;
|
||||
FreeAndNil(DL);
|
2
sources/cdejecter_dll/data/lGetVolumeInfo_vars.inc
Normal file
2
sources/cdejecter_dll/data/lGetVolumeInfo_vars.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
var DL: TDrivesList;
|
||||
Ind: Byte;
|
26
sources/cdejecter_dll/data/wEjectCD_core.inc
Normal file
26
sources/cdejecter_dll/data/wEjectCD_core.inc
Normal file
@@ -0,0 +1,26 @@
|
||||
Result:= False;
|
||||
if ADisc = '' then
|
||||
Abort;
|
||||
S:= ADisc + ':';
|
||||
if GetDriveType(PChar(S)) = DRIVE_CDROM then
|
||||
begin
|
||||
Flags:= mci_Open_Type or mci_Open_Element;
|
||||
with OpenParm do
|
||||
begin
|
||||
dwCallback:= 0;
|
||||
lpstrDeviceType:= 'CDAudio';
|
||||
lpstrElementName:= PChar(S);
|
||||
end;
|
||||
Res:= mciSendCommand(0, mci_Open, Flags, Longint(@OpenParm));
|
||||
if Res <> 0 then
|
||||
Exit;
|
||||
DeviceID:= OpenParm.wDeviceID;
|
||||
try
|
||||
Res:= mciSendCommand(DeviceID, MCI_SET, MCI_SET_DOOR_OPEN, 0);
|
||||
if Res = 0 then
|
||||
Exit;
|
||||
Result:= True;
|
||||
finally
|
||||
mciSendCommand(DeviceID, mci_Close, Flags, Longint(@OpenParm));
|
||||
end;
|
||||
end;
|
5
sources/cdejecter_dll/data/wEjectCD_vars.inc
Normal file
5
sources/cdejecter_dll/data/wEjectCD_vars.inc
Normal file
@@ -0,0 +1,5 @@
|
||||
var Res: MciError;
|
||||
OpenParm: TMCI_Open_Parms;
|
||||
Flags: DWord;
|
||||
S: String;
|
||||
DeviceID: Word;
|
14
sources/cdejecter_dll/data/wGetCDDiscs_core.inc
Normal file
14
sources/cdejecter_dll/data/wGetCDDiscs_core.inc
Normal file
@@ -0,0 +1,14 @@
|
||||
GetLogicalDriveStrings(96, Buf);
|
||||
for j:=0 to 25 do
|
||||
if Buf[j*4+2] <> #92 then
|
||||
Break;
|
||||
SL:= TStringListUTF8.Create;
|
||||
for i:=0 to j-1 do
|
||||
begin
|
||||
if GetDriveType(@Buf[i*4])= DRIVE_CDROM then
|
||||
SL.Add(AnsiLowerCase(String(Buf[i*4])) + ':\');
|
||||
end;
|
||||
SL.Delimiter:= ';';
|
||||
Result:= PWideChar(SL.DelimitedText);
|
||||
SL.Clear;
|
||||
SL.Free;
|
3
sources/cdejecter_dll/data/wGetCDDiscs_vars.inc
Normal file
3
sources/cdejecter_dll/data/wGetCDDiscs_vars.inc
Normal file
@@ -0,0 +1,3 @@
|
||||
var i, j : Integer;
|
||||
Buf : array [0..95] of Char;
|
||||
SL: TStringListUTF8;
|
17
sources/cdejecter_dll/data/wGetVolumeInfo_core.inc
Normal file
17
sources/cdejecter_dll/data/wGetVolumeInfo_core.inc
Normal file
@@ -0,0 +1,17 @@
|
||||
s:= ADisc + ':\';
|
||||
root:= PChar(s);
|
||||
GetMem(VolumeNameBuffer, 256);
|
||||
Getmem(FileSystemNameBuffer, 256);
|
||||
VolumeNameSize:= 255;
|
||||
FileSystemNameSize:= 255;
|
||||
res:= GetVolumeInformation(Root, VolumeNameBuffer, VolumeNameSize, @VolumeSerialNumber, MaximumComponentLength, FileSystemFlags, FileSystemNameBuffer, FileSystemNameSize);
|
||||
with Result do
|
||||
begin
|
||||
diHasInfo:= res;
|
||||
diDrive:= ADisc;
|
||||
diVolumeName:= VolumeNameBuffer;
|
||||
diFileSystem:= FileSystemNameBuffer;
|
||||
diSerial:= VolumeSerialNumber;
|
||||
end;
|
||||
Freemem(VolumeNameBuffer, 256);
|
||||
Freemem(FileSystemNameBuffer, 256);
|
6
sources/cdejecter_dll/data/wGetVolumeInfo_vars.inc
Normal file
6
sources/cdejecter_dll/data/wGetVolumeInfo_vars.inc
Normal file
@@ -0,0 +1,6 @@
|
||||
var root: PChar;
|
||||
res: LongBool;
|
||||
VolumeNameBuffer, FileSystemNameBuffer: PChar;
|
||||
VolumeNameSize,FileSystemNameSize: DWORD;
|
||||
VolumeSerialNumber, MaximumComponentLength, FileSystemFlags: DWORD;
|
||||
s: String;
|
Reference in New Issue
Block a user