Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
	
- Functions.module: Corrected bug in getFreePartSpace's NTFS
	implementation (used bytes where being identified as unused
	bytes).

- Utils.module: Subroutine Parse_fdisk renamed to ProcessDiskInfo
	since fdisk parsing is now only one of many things done in this
	sub.
	---
	Added code to ProcessDiskInfo to gather information about
	unallocated bytes on each disk drive.

- frmPartSelect.class: The "Units" column in gridDisk replaced with
	"Unallocated". This column now displays the unallocated
	(unpartitioned) space of each disk drive.
  • Loading branch information
easuter committed Sep 12, 2007
1 parent f7840ba commit 036868a
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 54 deletions.
28 changes: 14 additions & 14 deletions .lang/.pot
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ msgstr ""
msgid "Advanced selection"
msgstr ""

#: frmPackages.class:147 frmPartitions.class:266
#: frmPackages.class:147 frmPartitions.class:265
msgid "Manual"
msgstr ""

Expand Down Expand Up @@ -373,7 +373,7 @@ msgid ""
"</ul>\n"
msgstr ""

#: frmPartitions.class:217
#: frmPartitions.class:216
msgid ""
"<center><h3><b>Available partitioning modes:</b></h3></center>\n"
"\n"
Expand All @@ -384,8 +384,8 @@ msgid ""
"disk for VL. <font color=\"#FF0000\">WARNING: this option will DELETE "
"everything on your hard disk, or offer a choice if there are multiple disks. "
"You have been WARNED.</font></li>\n"
"<li><b>Free space:</b> using available free (unpartitioned) disk space.</"
"li>\n"
"<li><b>Unpartitioned space:</b> using available free (unpartitioned) disk "
"space.</li>\n"
"</ul>\n"
"<b><u>Manual partitioning:</u></b> You have full control of partitioning.\n"
"<ul>\n"
Expand All @@ -402,39 +402,39 @@ msgid ""
"</ul>\n"
msgstr ""

#: frmPartitions.class:229
#: frmPartitions.class:228
msgid "Partitioning mode"
msgstr ""

#: frmPartitions.class:244
#: frmPartitions.class:243
msgid "Automatic"
msgstr ""

#: frmPartitions.class:251
#: frmPartitions.class:250
msgid "Full disk"
msgstr ""

#: frmPartitions.class:259
msgid "Free space"
#: frmPartitions.class:258
msgid "Unpartitioned space"
msgstr ""

#: frmPartitions.class:273
#: frmPartitions.class:272
msgid "GParted"
msgstr ""

#: frmPartitions.class:281
#: frmPartitions.class:280
msgid "cfdisk"
msgstr ""

#: frmPartitions.class:288
#: frmPartitions.class:287
msgid "Others"
msgstr ""

#: frmPartitions.class:295
#: frmPartitions.class:294
msgid "Preset strategies"
msgstr ""

#: frmPartitions.class:303
#: frmPartitions.class:302
msgid "No partitioning"
msgstr ""

Expand Down
26 changes: 13 additions & 13 deletions .lang/frmPartitions.pot
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,47 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: frmPartitions.class:217
msgid "<center><h3><b>Available partitioning modes:</b></h3></center>\n\n<b><u>Automatic partitioning:</u></b> The installer will handle all partition related decisions for you:\n<ul>\n<li><b>Full disk:</b> Choose this option if you want to use your entire hard disk for VL. <font color=\"#FF0000\">WARNING: this option will DELETE everything on your hard disk, or offer a choice if there are multiple disks. You have been WARNED.</font></li>\n<li><b>Free space:</b> using available free (unpartitioned) disk space.</li>\n</ul>\n<b><u>Manual partitioning:</u></b> You have full control of partitioning.\n<ul>\n<li><b>Using gparted</b> (the advanced graphical partitioner).</li>\n<li><b>Using cfdisk</b> (the traditional partition tool).</li>\n</ul>\n<b><u>Other partitioning:</u></b>\n<ul>\n<li><b>Preset strategies:</b> auto allocates partitions according to most common usage strategy intended for this computer.</li>\n<li><b>No partitioning:</b> If you wish to use existing Linux and swap partitions. <font color=\"#FF0000\">WARNING: The existing Linux partitions will be OVERWRITTEN. You have been WARNED.</font></li>\n</ul>\n"
#: frmPartitions.class:216
msgid "<center><h3><b>Available partitioning modes:</b></h3></center>\n\n<b><u>Automatic partitioning:</u></b> The installer will handle all partition related decisions for you:\n<ul>\n<li><b>Full disk:</b> Choose this option if you want to use your entire hard disk for VL. <font color=\"#FF0000\">WARNING: this option will DELETE everything on your hard disk, or offer a choice if there are multiple disks. You have been WARNED.</font></li>\n<li><b>Unpartitioned space:</b> using available free (unpartitioned) disk space.</li>\n</ul>\n<b><u>Manual partitioning:</u></b> You have full control of partitioning.\n<ul>\n<li><b>Using gparted</b> (the advanced graphical partitioner).</li>\n<li><b>Using cfdisk</b> (the traditional partition tool).</li>\n</ul>\n<b><u>Other partitioning:</u></b>\n<ul>\n<li><b>Preset strategies:</b> auto allocates partitions according to most common usage strategy intended for this computer.</li>\n<li><b>No partitioning:</b> If you wish to use existing Linux and swap partitions. <font color=\"#FF0000\">WARNING: The existing Linux partitions will be OVERWRITTEN. You have been WARNED.</font></li>\n</ul>\n"
msgstr ""

#: frmPartitions.class:229
#: frmPartitions.class:228
msgid "Partitioning mode"
msgstr ""

#: frmPartitions.class:244
#: frmPartitions.class:243
msgid "Automatic"
msgstr ""

#: frmPartitions.class:251
#: frmPartitions.class:250
msgid "Full disk"
msgstr ""

#: frmPartitions.class:259
msgid "Free space"
#: frmPartitions.class:258
msgid "Unpartitioned space"
msgstr ""

#: frmPartitions.class:266
#: frmPartitions.class:265
msgid "Manual"
msgstr ""

#: frmPartitions.class:273
#: frmPartitions.class:272
msgid "GParted"
msgstr ""

#: frmPartitions.class:281
#: frmPartitions.class:280
msgid "cfdisk"
msgstr ""

#: frmPartitions.class:288
#: frmPartitions.class:287
msgid "Others"
msgstr ""

#: frmPartitions.class:295
#: frmPartitions.class:294
msgid "Preset strategies"
msgstr ""

#: frmPartitions.class:303
#: frmPartitions.class:302
msgid "No partitioning"
msgstr ""

2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Title=VL-gui-installer
Startup=Main
Icon=vl_logo_icon2.png
Version=0.0.238
Version=0.0.254
Library=gb.qt
Library=gb.qt.ext
TabSize=3
Expand Down
2 changes: 1 addition & 1 deletion .settings
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Count=0

[FFind]
SearchIn="Module"
SearchIn="Sub"
CaseSensitive=True
SearchWord=False
SearchComment=False
Expand Down
10 changes: 6 additions & 4 deletions Functions.module
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ DIM sTemp AS String
DIM sTemp2 AS String
DIM sFreeBlocks AS String
DIM sBlockSize AS String
DIM sUsedBlocks AS String
DIM arrTemp AS NEW String[]
DIM iFreeBytes AS Long

Expand Down Expand Up @@ -281,21 +282,22 @@ ELSE IF sFilesystem = "NTFS" THEN
SHELL "ntfsresize --info --force --no-progress-bar " & sDevice TO sTemp
sTemp = Trim$(sTemp)
arrTemp = Split(sTemp, Chr$(10))
PRINT arrTemp[10]
'It would be a lot easier to use an expression in the output of ntfsresize to identify the number of free bytes, but that is not i18n ready!
'So "chomp" away portions of the string until the first integer is found (this will be the free space value)
sTemp = arrTemp[10]
WHILE Len(sTemp) > 0
sTemp2 = Trim$(Left$(sTemp, InStr(sTemp, Space$(1))))
IF IsInteger(Val(sTemp2)) OR IsLong(Val(sTemp2)) THEN
sFreeBlocks = CLng(Val(sTemp2))
sUsedBlocks = CLng(Val(sTemp2))
BREAK
ELSE
sTemp = Trim$(Mid$(sTemp, InStr(sTemp, Space$(1))))
ENDIF
WEND
sBlockSize = Trim$(Mid$(Left$(arrTemp[3], RInStr(arrTemp[3], Space$(1))), InStr(arrTemp[3], ":") + 1))
iFreeBytes = CLng(sFreeBlocks) * CLng(sBlockSize)
'sBlockSize = Trim$(Mid$(Left$(arrTemp[3], RInStr(arrTemp[3], Space$(1))), InStr(arrTemp[3], ":") + 1))
sTemp = Trim$(Mid$(arrTemp[5], InStr(arrTemp[5], ":") + 1)) 'Get total partition size
sTemp2 = Trim$(Left(sTemp, InStr(sTemp, Space$(1))))
iFreeBytes = CLng(sTemp2) - CLng(sUsedBlocks)
ELSE
iFreeBytes = 0
ENDIF
Expand Down
2 changes: 1 addition & 1 deletion Global.class
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ STATIC PUBLIC enumPACKS AS Long 'Package selection mode.
' 3 = No extras
STATIC PUBLIC enumPARTMODE AS Long 'Partitioning mode.
' 0 = Full disk
' 1 = Free space
' 1 = Unpartitioned space
' 2 = GParted
' 3 = cfdisk
' 4 = Preset strategies
Expand Down
40 changes: 33 additions & 7 deletions Utils.module
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,22 @@ ELSE
ENDIF

' Parse what fdisk has to say:
Parse_fdisk(sTemp)
'Get filesystem data
'getFileSystems()
ProcessDiskInfo(sTemp)


END

PUBLIC SUB Parse_fdisk(sTemp AS String)
' Parse what fdisk has to say:
PUBLIC SUB ProcessDiskInfo(sTemp AS String)
' Parse what fdisk has to say, including other commands for useful hard-drive/partition information
DIM vDI AS NEW cDiskInfo
DIM vPI AS NEW cPartInfo
DIM arrTemp1 AS NEW String[]
DIM arrTemp2 AS NEW String[]
DIM arrTemp3 AS NEW String[]
DIM sTemp2 AS String
DIM iDisk AS Long
DIM iPart AS Long
DIM iDiskUsedBytes AS Long
DIM pos AS Long
DIM n AS Long, m AS Long
DIM pcounter AS Long
Expand All @@ -79,7 +81,7 @@ IF Global.DebugMode = TRUE THEN
message.Info("Working in Simulation Mode..." & gb.NewLine & sTemp)
ENDIF

' Parse it:
' Parse fdisk
arrTemp1 = Split(sTemp, Chr$(10))
FOR n = 0 TO arrTemp1.Max
pos = InStr(arrTemp1[n], "/dev/")
Expand Down Expand Up @@ -110,6 +112,7 @@ FOR n = 0 TO arrTemp1.Max
vPI.ID = arrTemp2[4]
ENDIF

'Get filesystem information from "disktype"
IF Functions.getPartType(vPI.ID) = "Extended" THEN
vPI.FileSystem = "Extended"
ELSE IF Functions.getPartType(vPI.ID) = "HPFS/NTFS" THEN
Expand All @@ -121,7 +124,12 @@ FOR n = 0 TO arrTemp1.Max
vPI.FileSystem = Trim$(Left$(arrTemp3[2], InStr(arrTemp3[2], Space$(1))))
ENDIF

vPI.FreeBytes = Functions.getFreePartSpace(vPI.Device, vPI.FileSystem)
'Get free space information for each partition based on the filesystem
IF vPI.FileSystem = "Blank" THEN
vPI.FreeBytes = vPI.Bytes
ELSE
vPI.FreeBytes = Functions.getFreePartSpace(vPI.Device, vPI.FileSystem)
ENDIF

Global.PartInfo.Push(vPI)
ELSE IF pos > 1 ' Parse a disk drive.
Expand All @@ -133,11 +141,29 @@ FOR n = 0 TO arrTemp1.Max
ELSE
vDI.Bytes = Val(arrTemp2[3])
ENDIF

Global.DiskInfo.Push(vDI)
ELSE ' Nothing.
END IF
NEXT

'Get unallocated space on the hard-drives (it would be cool to have this in the main FOR loop...
'but its only possible after knowing each partiton's size)
FOR iDisk = 0 TO Global.DiskInfo.Max
iDiskUsedBytes = 0 'Reset the used-bytes counter
FOR iPart = 0 TO Global.PartInfo.Max
IF InStr(Global.PartInfo[iPart].Device, Global.DiskInfo[iDisk].Device) THEN
IF Global.PartInfo[iPart].FileSystem <> "Extended" THEN 'Ignore extended partitions, only account for primary and logical ones
iDiskUsedBytes = iDiskUsedBytes + Global.PartInfo[iPart].Bytes
ENDIF
ENDIF
NEXT
Global.DiskInfo[iDisk].UnallocatedBytes = Global.DiskInfo[iDisk].Bytes - iDiskUsedBytes
PRINT global.DiskInfo[iDisk].UnallocatedBytes
NEXT



' 4 debug:
IF Global.DebugMode = TRUE THEN
FOR n = 0 TO Global.DiskInfo.Max
Expand Down
1 change: 1 addition & 0 deletions cDiskInfo.class
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
' Structure for drive information array:
PUBLIC Device AS String
PUBLIC Bytes AS Long
PUBLIC UnallocatedBytes AS Long
16 changes: 8 additions & 8 deletions frmPartSelect.class
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ Global.PARTinst.Clear
gridDisk.Columns.Count = 4
'gridDisk.Rows.Count = MaxDisks
gridDisk.Rows.Count = 32
gridDisk.Columns[0].Width = 0.4 * gridDisk.ClientWidth
gridDisk.Columns[0].Width = 0.35 * gridDisk.ClientWidth
gridDisk.Columns[1].Width = 0.25 * gridDisk.ClientWidth
gridDisk.Columns[2].Width = 0.2 * gridDisk.ClientWidth
gridDisk.Columns[2].Width = 0.25 * gridDisk.ClientWidth
gridDisk.Columns[3].Width = 0.15 * gridDisk.ClientWidth

'Center gridDisk titles alignment:
Expand All @@ -37,7 +37,7 @@ NEXT
'Setup gridDisk titles:
gridDisk[0, 0].Text = "Drive"
gridDisk[0, 1].Text = "Size"
gridDisk[0, 2].Text = "Units"
gridDisk[0, 2].Text = "Unallocated"
gridDisk[0, 3].Text = "Sel."

'Set gridDisk cell alignment; left for text, right for numbers, fill in gridDisk data:
Expand All @@ -46,11 +46,11 @@ FOR m = 1 TO MaxDisks
gridDisk.Rows[m].Height = 20
gridDisk[m, 0].Text = Global.DiskInfo[m - 1].Device
gridDisk[m, 1].Alignment = Align.Right
gridDisk[m, 1].Text = Global.DiskInfo[m - 1].Bytes
arrTemp = Split(Functions.AutoUnits(Global.DiskInfo[m - 1].Bytes), " ", "", TRUE)
gridDisk[m, 1].Text = arrTemp[0]
gridDisk[m, 2].Alignment = Align.Left
gridDisk[m, 2].Text = arrTemp[1]
gridDisk[m, 1].Text = Functions.AutoUnits(Global.DiskInfo[m - 1].Bytes)
'arrTemp = Split(Functions.AutoUnits(Global.DiskInfo[m - 1].Bytes), " ", "", TRUE)
'gridDisk[m, 1].Text = arrTemp[0]
gridDisk[m, 2].Alignment = Align.Right
gridDisk[m, 2].Text = Functions.AutoUnits(Global.DiskInfo[m - 1].UnallocatedBytes)
gridDisk[m, 3].Alignment = Align.Center
NEXT

Expand Down
1 change: 0 additions & 1 deletion frmPartitions.class
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,3 @@ frmPartSelect.ShowModal
Global.flagBUTTExec = FALSE

END

8 changes: 4 additions & 4 deletions frmPartitions.form
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Gambas Form File 2.0

{ Form Form
MoveScaled(4,6,90.5714,78.2857)
MoveScaled(4,6,90.5,78.25)
Font = Font["Luxi Sans"]
Background = &HFFFFFF&
Text = ("")
Expand All @@ -18,7 +18,7 @@
Background = &HDFFFFF&
Padding = 10
AutoResize = True
Text = ("<center><h3><b>Available partitioning modes:</b></h3></center>\n\n<b><u>Automatic partitioning:</u></b> The installer will handle all partition related decisions for you:\n<ul>\n<li><b>Full disk:</b> Choose this option if you want to use your entire hard disk for VL. <font color=\"#FF0000\">WARNING: this option will DELETE everything on your hard disk, or offer a choice if there are multiple disks. You have been WARNED.</font></li>\n<li><b>Free space:</b> using available free (unpartitioned) disk space.</li>\n</ul>\n<b><u>Manual partitioning:</u></b> You have full control of partitioning.\n<ul>\n<li><b>Using gparted</b> (the advanced graphical partitioner).</li>\n<li><b>Using cfdisk</b> (the traditional partition tool).</li>\n</ul>\n<b><u>Other partitioning:</u></b>\n<ul>\n<li><b>Preset strategies:</b> auto allocates partitions according to most common usage strategy intended for this computer.</li>\n<li><b>No partitioning:</b> If you wish to use existing Linux and swap partitions. <font color=\"#FF0000\">WARNING: The existing Linux partitions will be OVERWRITTEN. You have been WARNED.</font></li>\n</ul>\n")
Text = ("<center><h3><b>Available partitioning modes:</b></h3></center>\n\n<b><u>Automatic partitioning:</u></b> The installer will handle all partition related decisions for you:\n<ul>\n<li><b>Full disk:</b> Choose this option if you want to use your entire hard disk for VL. <font color=\"#FF0000\">WARNING: this option will DELETE everything on your hard disk, or offer a choice if there are multiple disks. You have been WARNED.</font></li>\n<li><b>Unpartitioned space:</b> using available free (unpartitioned) disk space.</li>\n</ul>\n<b><u>Manual partitioning:</u></b> You have full control of partitioning.\n<ul>\n<li><b>Using gparted</b> (the advanced graphical partitioner).</li>\n<li><b>Using cfdisk</b> (the traditional partition tool).</li>\n</ul>\n<b><u>Other partitioning:</u></b>\n<ul>\n<li><b>Preset strategies:</b> auto allocates partitions according to most common usage strategy intended for this computer.</li>\n<li><b>No partitioning:</b> If you wish to use existing Linux and swap partitions. <font color=\"#FF0000\">WARNING: The existing Linux partitions will be OVERWRITTEN. You have been WARNED.</font></li>\n</ul>\n")
}
}
{ VBox1 VBox
Expand Down Expand Up @@ -49,12 +49,12 @@
Foreground = Color.ButtonForeground
Text = ("Full disk")
}
{ btnFreeSpace Button
{ btnUnpartSpace Button
MoveScaled(1,9,23,5)
Font = Font["Luxi Sans,14"]
Background = Color.ButtonBackground
Foreground = Color.ButtonForeground
Text = ("Free space")
Text = ("Unpartitioned space")
}
}
{ Frame2 Frame
Expand Down

0 comments on commit 036868a

Please sign in to comment.