Retrieve volumes list
Posted: Tue Sep 10, 2024 4:57 pm
How can I retrieve the list of the system volumes and in case of amiga os the list of the assignes too
Thanks
Thanks
The Cross-Platform Multimedia Application Layer
https://www.hollywood-mal.com/forums/
It is quite quick and simple.For V = 1 To 26 ; Go Through All Drive Letters
If Exists(Chr(64 + V) .. ":")
DebugPrint(Chr(64 + V) .. " Drive")
EndIf
Next
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; * Find all devices ** ( No assigns ) *************************************** Non Mui Royale ***********
devices = {}
harddisks = {}
optical = {}
usb = {}
ram = {}
Devs = {}
Function ListDrives()
Execute("info devices sort volume >TEXTCLIP:")
type, data = GetClipboard()
h = 0
o = 0
u = 0
r = 0
devices, noofdevices = SplitStr(data,"\n")
For Local x = 1 To noofdevices-1
Line = devices[x-1]
If FindStr(Line,"DH",False) = 0
harddisks[h] = MidStr(Line,0, FindStr(Line,":"))
h = h +1
ElseIf FindStr(Line,"CD",False) = 0
optical[o] = MidStr(Line,0, FindStr(Line,":"))
o = o +1
ElseIf FindStr(Line,"USB",False) = 0
usb = MidStr(Line,0, FindStr(Line,":"))
u = u +1
ElseIf FindStr(Line,"RAM",False) = 0
ram[r] = MidStr(Line,0, FindStr(Line,":"))
r = r +1
EndIf
Next
L=1
For Local d = 0 To h-1
TextOut(5,L*14,Harddisks[d])
Devs[l] = Harddisks[d]
L = L +1
Next
For Local d = 0 To o-1
TextOut(5,L*14,Optical[d])
Devs[l] = Optical[d]
L = L +1
Next
For Local d = 0 To u-1
TextOut(5,L*14,Usb[d])
Devs[l] = Usb[d]
L = L +1
Next
For Local d = 0 To r-1
TextOut(5,L*14,ram[d])
Devs[l] = ram[d]
L = L +1
Next
EndFunction
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Hope that helps/*** Make sure we have at least Hollywood 9.0! ****************************************************/
@VERSION 5,2
/*** Enable DPI-awareness so that our GUI looks sharp even on high DPI monitors *******************/
@OPTIONS {DPIAware = True}
/*** This script requires the RapaGUI plugin ******************************************************/
@REQUIRE "MUIRoyale"
/*** Information about this app *******************************************************************/
@APPTITLE "Simple DIRLook"
@APPVERSION "$VER: 1.0.0 (16.07.20)"
@APPCOPYRIGHT "George Leo den Hollander 2020"
@APPAUTHOR "Leo den Hollander"
@APPDESCRIPTION "Simple DIR Program"
@DISPLAY {Hidden = True}
EscapeQuit(True)
activelist = 2
/*** setup GUI ***********************************************************************************/
MUI.CREATEGUI([[
<?xml version="1.0" encoding="iso-8859-1"?>
<application base="TEST">
<window title="DIR LOOK - Directory Program" id="window" notify="closerequest" width="1280" height="600">
<vgroup background="pre_ShadowFill">
<hgroup>
<vgroup>
<button id="leftpanel" notify="Pressed" BackGroundRGB="#B0B0B0"></button>
<dirlist id="lv1_directory" notify="Active; Doubleclick" directory="DH0:" multiselect="default" title="true" fixheight="800" fixwidth="550">
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
</dirlist>
<string id="lv1" contents="DH0:"/>
</vgroup>
<vgroup weight="70">
<vgroup id = "container" font="Big" >
<vspace height="1"/>
<label centered="true">\333\33bDRIVES</label>
<volumelist id="vol" notify="DoubleClick" fixwidth="150">
<column/>
<column/>
</volumelist>
</vgroup>
<vgroup font="Big">
<label centered="true">\333\33bFUNCTIONS</label>
<button id ="parent" notify="pressed" fixwidth="100">\33b Parent Dir </button>
<button id ="copy" notify="pressed" fixwidth="100">\33b Copy File </button>
<button id ="rename" notify="pressed" fixwidth="100">\33b Rename File</button>
<button id ="delete" notify="pressed" fixwidth="100">\33b Delete File </button>
<button id ="find" notify="pressed" fixwidth="100">\33b Find File </button>
<button id ="makedir" notify="pressed" fixwidth="100">\33b Make Dir </button>
<button id ="comment" notify="pressed" fixwidth="100">\33b File Comment </button>
</vgroup>
<vgroup>
<button id ="quit" notify="pressed" fixwidth="100">\33b Quit </button>
</vgroup>
</vgroup>
<vgroup>
<button id="rightpanel" Notify="Pressed" BackGroundRGB="#80AAFF"></button>
<dirlist id="lv2_directory" notify="Active; DoubleClick" directory="RAM:" multiselect="default" title="TRUE" fixheight="800" fixwidth="550">
<column/>
<column/>
<column/>
<column/>
<column/>
<column/>
</dirlist>
<string id="lv2" contents="RAM:"/>
</vgroup>
</hgroup>
</vgroup>
</window>
</application>
]])
;*** Handler for all incoming events **************************************************************
Function p_EventFunc(msg)
Switch msg.action
Case "MUIRoyale":
Switch msg.attribute
Case "CloseRequest":
End
Case "Pressed":
Switch msg.id
Case "rightpanel"
mui.Set("leftpanel", "BackGroundRGB", RGB(176, 176, 176))
mui.Set("rightpanel", "BackGroundRGB", RGB(128, 170, 255))
Activelist = 2
Case "leftpanel"
mui.Set("rightpanel", "BackGroundRGB", RGB(176, 176, 176))
mui.Set("leftpanel", "BackGroundRGB", RGB(128, 170, 255))
Activelist = 1
Case "parent":
If activelist = 1
newpar1$ = MUI.GET("lv" .. Activelist,"contents")
len = StrLen(newpar1$)
newpar1$ = LeftStr(newpar1$,len-1)
For Local t = len-1 To 0 Step -1
var = FindStr(newpar1$,"/",False,t)
If var > -1
newpar1$ = LeftStr(newpar1$,var+1)
Break
EndIf
Next
If var = -1
newpar1$ = MUI.GET("lv" .. Activelist,"contents")
len = StrLen(newpar1$)-1
For Local t = len To 0 Step -1
var = FindStr(newpar1$,":",False,t)
If var > -1
newpar1$ = LeftStr(newpar1$,var+1)
Break
EndIf
Next
EndIf
MUI.SET("lv" .. Activelist,"contents",newpar1$)
MUI.SET("lv" .. Activelist .. "_directory","directory",newpar1$)
ElseIf activelist = 2
newpar2$ = MUI.GET("lv" .. Activelist,"contents")
len = StrLen(newpar2$)
newpar2$ = LeftStr(newpar2$,len-1)
For t = len-1 To 0 Step -1
var = FindStr(newpar2$,"/",False,t)
If var > -1
newpar2$ = LeftStr(newpar2$,var+1)
Break
EndIf
Next
If var = -1
newpar2$ = MUI.GET("lv" .. Activelist,"contents")
len = StrLen(newpar2$)-1
For Local t = len To 0 Step -1
var = FindStr(newpar2$,":",False,t)
If var > -1
newpar2$ = LeftStr(newpar2$,var+1)
Break
EndIf
Next
EndIf
MUI.SET("lv" .. Activelist,"contents",newpar2$)
MUI.SET("lv" .. Activelist .. "_directory","directory",newpar2$)
EndIf
EndSwitch
Case "DoubleClick":
Switch msg.id
Case "vol"
Col1$ = mui.DoMethod("vol", "GetEntry", "Active")
mui.Set("lv" .. Activelist .. "_directory", "Directory", Col1$)
Case "lv1_directory"
newdir1$ = mui.Get("lv1","contents")
Column1$,Column2 = mui.DoMethod("lv1_directory","GetEntry","Active")
If Column2 = -1
mui.Set("lv" .. Activelist .. "_directory", "directory", newdir1$ .. Column1$)
mui.Set("lv" .. Activelist, "contents", newdir1$ .. Column1$ .. "/")
Else
Execute("DH0:Utilities/MultiView ")
EndIf
Case "lv2_directory"
newdir2$ = MUI.GET("lv2","contents")
Column1$,Column2 = mui.DoMethod("lv2_directory","GetEntry","Active")
If Column2 = -1
MUI.Set("lv" .. Activelist .. "_directory","directory",newdir2$..Column1$)
MUI.Set("lv" .. Activelist, "contents",newdir2$..Column1$.."/")
Else
Execute("DH0:Utilities/MultiView ")
EndIf
EndSwitch
EndSwitch
Case "HideWindow":
mui.Set("app", "iconified", True)
Case "ShowWindow":
mui.Set("app", "iconified", False)
EndSwitch
EndFunction
;*** listen to these events ***********************************************************************
InstallEventHandler({MUIRoyale = p_EventFunc, HideWindow = p_EventFunc, ShowWindow = p_EventFunc})
;*** main loop ***********************************************************************************
Repeat
WaitEvent
Forever
Code: Select all
Function p_GetAssign()
Local table = {volumes = {}, assigns = {}, devices = {}}
If Exists("C:Assign")
Local file$ = "T:AssignList.txt"
Execute("C:Assign > " .. file$)
Local vols$, dirs$, devs$ = PatternFindStrShort(FileToString(file$), "Volumes:\n(.*)Directories:\n(.*)Devices:\n(.*)")
DeleteFile(file$)
For name$ In PatternFindStr(vols$, "(.-) %[Mounted%]") Do InsertItem(table.volumes, name$)
For name$ In PatternFindStr(dirs$, "(.-) .-\n") Do InsertItem(table.assigns, name$)
For name$ In PatternFindStr(devs$, "%g+") Do InsertItem(table.devices, name$)
EndIf
Return(table)
EndFunction
t = p_GetAssign()
DebugPrint("--- Volumes ---")
For Local i = 0 To ListItems(t.volumes) - 1
DebugPrint(t.volumes[i])
Next
DebugPrint("--- Assigns ---")
For Local i = 0 To ListItems(t.assigns) - 1
DebugPrint(t.assigns[i])
Next
DebugPrint("--- Devices ---")
For Local i = 0 To ListItems(t.devices) - 1
DebugPrint(t.devices[i])
Next
Code: Select all
Datenträger:
RAM Disk[Angemeldet]Code: Select all
Volumes :
RAM Disk [Monté]Code: Select all
Function p_GetAssign()
Local table = {volumes = {}, assigns = {}, devices = {}}
If Exists("C:Assign")
Local file$ = "T:AssignList.txt"
Execute("C:Assign > " .. file$)
Local list$ = FileToString(file$)
If Not ValidateStr(list$) Then list$ = ConvertStr(list$, #ENCODING_AMIGA, #ENCODING_UTF8)
Local vols$, dirs$, devs$ = PatternFindStrShort(list$, "^%g-%s?:\n(.*)\n%g-%s?:\n(.*)\n%g-%s?:\n(.*)")
DeleteFile(file$)
For name$ In PatternFindStr(vols$, "(.-)%s?%[.-%]") Do InsertItem(table.volumes, name$)
For name$ In PatternFindStr(dirs$, "(.-)%s.-\n") Do InsertItem(table.assigns, name$)
If FindStr(devs$, ":") > -1 Then devs$ = PatternFindStrShort(devs$, "(.-)\n\n") ; For OS 3.2 (Denied volume requests:)
For name$ In PatternFindStr(devs$, "%g+") Do InsertItem(table.devices, name$)
EndIf
Return(table)
EndFunction
t = p_GetAssign()
DebugPrint("--- Volumes ---")
For Local i = 0 To ListItems(t.volumes) - 1
DebugPrint(t.volumes[i])
Next
DebugPrint("--- Assigns ---")
For Local i = 0 To ListItems(t.assigns) - 1
DebugPrint(t.assigns[i])
Next
DebugPrint("--- Devices ---")
For Local i = 0 To ListItems(t.devices) - 1
DebugPrint(t.devices[i])
Next
Code: Select all
Function p_GetAssign()
Local table = {volumes = {}, assigns = {}, devices = {}}
If Exists("C:Assign")
Local file$ = "T:AssignList.txt"
Execute("C:Assign > " .. file$)
Local list$ = FileToString(file$)
If Not ValidateStr(list$) Then list$ = ConvertStr(list$, #ENCODING_AMIGA, #ENCODING_UTF8)
Local vols$, dirs$, devs$ = PatternFindStrShort(list$, "^%g-%s?:\n(.*)\n%g-%s?:\n(.*)\n%g-%s?:\n(.*)")
DeleteFile(file$)
For name$ In PatternFindStr(vols$, "(.-)%s?%[.-%]\n") Do InsertItem(table.volumes, name$)
For name$ In PatternFindStr(dirs$, "(.-)%s.-\n") Do InsertItem(table.assigns, name$)
If FindStr(devs$, ":") > -1 Then devs$ = PatternFindStrShort(devs$, "(.-)\n\n") ; For OS 3.2 (Denied volume requests:)
For name$ In PatternFindStr(devs$, "%g+") Do InsertItem(table.devices, name$)
Else
ConsolePrint("The C:Assign command not found.")
EndIf
Return(table)
EndFunction
t = p_GetAssign()
DebugPrint("--- Volumes ---")
For Local i = 0 To ListItems(t.volumes) - 1
DebugPrint(t.volumes[i], HaveVolume(t.volumes[i] .. ":"))
Next
DebugPrint("--- Assigns ---")
For Local i = 0 To ListItems(t.assigns) - 1
DebugPrint(t.assigns[i])
Next
DebugPrint("--- Devices ---")
For Local i = 0 To ListItems(t.devices) - 1
DebugPrint(t.devices[i])
Next