mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
UPD: Some checks to mount/unmount (Linux).
This commit is contained in:
parent
c8b350c867
commit
e5bcf72d80
4 changed files with 41 additions and 16 deletions
|
|
@ -356,6 +356,7 @@ begin
|
|||
|
||||
Drive^.IsMediaAvailable := DeviceIsMediaAvailable;
|
||||
Drive^.IsMediaEjectable := DeviceIsDrive and DriveIsMediaEjectable;
|
||||
Drive^.IsMediaRemovable := DeviceIsRemovable;
|
||||
Drive^.IsMounted := DeviceIsMounted;
|
||||
end;
|
||||
end;
|
||||
|
|
@ -388,6 +389,7 @@ begin
|
|||
DisplayName := Path;
|
||||
IsMediaAvailable := True;
|
||||
IsMediaEjectable := False;
|
||||
IsMediaRemovable := False;
|
||||
IsMounted := True;
|
||||
|
||||
case WinDriveType of
|
||||
|
|
@ -398,6 +400,7 @@ begin
|
|||
else
|
||||
DriveType := dtFlash;
|
||||
IsMediaEjectable := True;
|
||||
IsMediaRemovable := True;
|
||||
end;
|
||||
DRIVE_FIXED:
|
||||
DriveType := dtHardDisk;
|
||||
|
|
@ -407,6 +410,7 @@ begin
|
|||
begin
|
||||
DriveType := dtOptical;
|
||||
IsMediaEjectable := True;
|
||||
IsMediaRemovable := True;
|
||||
end;
|
||||
DRIVE_RAMDISK:
|
||||
DriveType := dtRamDisk;
|
||||
|
|
@ -522,6 +526,7 @@ begin
|
|||
DriveLabel:= volNameAsCString;
|
||||
IsMediaAvailable:= True;
|
||||
IsMediaEjectable:= False;
|
||||
IsMediaRemovable:= False;
|
||||
IsMounted:= True;
|
||||
end;
|
||||
Result.Add(Drive);
|
||||
|
|
@ -779,6 +784,7 @@ begin
|
|||
|
||||
IsMediaAvailable:= True;
|
||||
IsMediaEjectable:= (DriveType = dtOptical);
|
||||
IsMediaRemovable:= DriveType in [dtFloppy, dtOptical, dtFlash];
|
||||
IsMounted:= False; // Checked via mtab below.
|
||||
end;
|
||||
end
|
||||
|
|
@ -930,6 +936,7 @@ begin
|
|||
DriveType := dtype;
|
||||
IsMediaAvailable := false;
|
||||
IsMediaEjectable := false;
|
||||
IsMediaRemovable := false;
|
||||
IsMounted := false;
|
||||
end; { with }
|
||||
|
||||
|
|
@ -983,6 +990,7 @@ begin
|
|||
DriveType := dtype;
|
||||
IsMediaAvailable := true;
|
||||
IsMediaEjectable := false;
|
||||
IsMediaRemovable := false;
|
||||
IsMounted := true;
|
||||
end; { with }
|
||||
end; { for }
|
||||
|
|
|
|||
|
|
@ -276,8 +276,8 @@ var
|
|||
|
||||
procedure CheckPMount;
|
||||
begin
|
||||
HavePMount := (fpSystemStatus('pmount --version') = 0) and
|
||||
(fpSystemStatus('pumount --version') = 0);
|
||||
HavePMount := (fpSystemStatus('pmount --version > nul') = 0) and
|
||||
(fpSystemStatus('pumount --version > nul') = 0);
|
||||
end;
|
||||
|
||||
{$ENDIF LINUX}
|
||||
|
|
@ -455,27 +455,42 @@ end;
|
|||
|
||||
function MountDrive(const Drive: TDrive): Boolean;
|
||||
begin
|
||||
Result := fpSystemStatus('mount ' + Drive.DeviceId) = 0;
|
||||
{$IFDEF LINUX}
|
||||
if not Result and HavePMount then
|
||||
Result := fpSystemStatus('pmount ' + Drive.DeviceId) = 0;
|
||||
if not Drive.IsMounted then
|
||||
begin
|
||||
{$IF DEFINED(UNIX) AND NOT DEFINED(DARWIN)}
|
||||
Result := False;
|
||||
// If Path is not empty "mount" can mount it because it has a destination path from fstab.
|
||||
if Drive.Path <> EmptyStr then
|
||||
{$ENDIF}
|
||||
Result := fpSystemStatus('mount ' + Drive.DeviceId) = 0;
|
||||
{$IFDEF LINUX}
|
||||
if not Result and HavePMount and Drive.IsMediaRemovable then
|
||||
Result := fpSystemStatus('pmount ' + Drive.DeviceId) = 0;
|
||||
{$ENDIF}
|
||||
end
|
||||
else
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function UnmountDrive(const Drive: TDrive): Boolean;
|
||||
begin
|
||||
{$IFDEF LINUX}
|
||||
Result := False;
|
||||
if uUDisks.Initialize then
|
||||
if Drive.IsMounted then
|
||||
begin
|
||||
Result := uUDisks.Unmount(DeviceFileToUDisksObjectPath(Drive.DeviceId), nil);
|
||||
uUDisks.Finalize;
|
||||
end;
|
||||
if not Result and HavePMount then
|
||||
Result := fpSystemStatus('pumount ' + Drive.DeviceId) = 0;
|
||||
if not Result then
|
||||
{$IFDEF LINUX}
|
||||
Result := False;
|
||||
if uUDisks.Initialize then
|
||||
begin
|
||||
Result := uUDisks.Unmount(DeviceFileToUDisksObjectPath(Drive.DeviceId), nil);
|
||||
uUDisks.Finalize;
|
||||
end;
|
||||
if not Result and HavePMount and Drive.IsMediaRemovable then
|
||||
Result := fpSystemStatus('pumount ' + Drive.DeviceId) = 0;
|
||||
if not Result then
|
||||
{$ENDIF}
|
||||
Result := fpSystemStatus('umount ' + Drive.Path) = 0;
|
||||
Result := fpSystemStatus('umount ' + Drive.Path) = 0;
|
||||
end
|
||||
else
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function EjectDrive(const Drive: TDrive): Boolean;
|
||||
|
|
|
|||
|
|
@ -1774,7 +1774,8 @@ end;
|
|||
function TPixMapManager.GetDefaultDriveIcon(IconSize : Integer; clBackColor : TColor) : Graphics.TBitmap;
|
||||
var
|
||||
Drive: TDrive = (DisplayName: ''; Path: ''; DriveLabel: ''; DeviceId: ''; DriveType: dtHardDisk;
|
||||
IsMediaAvailable: True; IsMediaEjectable: False; IsMounted: True);
|
||||
IsMediaAvailable: True; IsMediaEjectable: False; IsMediaRemovable: False;
|
||||
IsMounted: True);
|
||||
begin
|
||||
Result := GetBuiltInDriveIcon(@Drive, IconSize, clBackColor);
|
||||
end;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ type
|
|||
DriveType : TDriveType;
|
||||
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.
|
||||
end;
|
||||
PDrive = ^TDrive;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue