Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
- Utils.module:
	Added an exception to the filesystem identification code, since
	disktype's output changes slightly when used against an ntfs partiton.
	Parse_fdisk sub also adds free space values for each filesystem.
	Maybe its time to call the Parse_fdisk sub something else ;)
	
- frmPartSelect.class: "Units" column replaced with the "Free Space"
	column. The "Size" and "Free Space" columns both display the
	units in the same cell as the value.
	Other small ajustments made due to changes in Functions.AutoUnits()

- Functions.module: The AutoUnits() function has been tuned to round
	sizes to two decimal units (x.xx), so as to be a bit more accurate
	with large disk sizes.
	--
	Created new function getFreePartSpace() that will return the free
	space of a partition, based on the filesystem.
	This was possible by looking at the gparted source code to see
	which commands  and options are best for each filesystem.
	So far these filesystems have been implemented: Ext2, Ext3, XFS and
	ReiserFS. 
	TODO: JFS, FAT16, FAT32, NTFS, Minix(?).
  • Loading branch information
easuter committed Sep 10, 2007
1 parent b9d3a54 commit 5a5cc1c
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 84 deletions.
42 changes: 21 additions & 21 deletions .lang/.pot
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ msgstr ""
msgid "Enter a value:"
msgstr ""

#: InputBox.class:205 frmDriveSelect.class:129 frmPartSelect.class:372
#: InputBox.class:205 frmDriveSelect.class:129 frmPartSelect.class:378
msgid "OK"
msgstr ""

#: InputBox.class:212 frmChooseFB.class:91 frmDriveSelect.class:136
#: frmPartSelect.class:379
#: frmPartSelect.class:385
msgid "Cancel"
msgstr ""

Expand Down Expand Up @@ -206,7 +206,7 @@ msgstr ""
msgid "Config 2"
msgstr ""

#: frmDriveSelect.class:110 frmPartSelect.class:347
#: frmDriveSelect.class:110 frmPartSelect.class:353
msgid "Drives"
msgstr ""

Expand All @@ -226,7 +226,7 @@ msgstr ""
msgid "The choice"
msgstr ""

#: frmMain.class:225 frmPartSelect.class:387
#: frmMain.class:225 frmPartSelect.class:393
msgid "Partitions"
msgstr ""

Expand Down Expand Up @@ -300,71 +300,71 @@ msgstr ""
msgid "No extras"
msgstr ""

#: frmPartSelect.class:261
#: frmPartSelect.class:267
msgid "Mountpoints"
msgstr ""

#: frmPartSelect.class:267
#: frmPartSelect.class:273
msgid "/"
msgstr ""

#: frmPartSelect.class:273
#: frmPartSelect.class:279
msgid "/home"
msgstr ""

#: frmPartSelect.class:279
#: frmPartSelect.class:285
msgid "/var"
msgstr ""

#: frmPartSelect.class:285
#: frmPartSelect.class:291
msgid "/opt"
msgstr ""

#: frmPartSelect.class:291
#: frmPartSelect.class:297
msgid "/tmp"
msgstr ""

#: frmPartSelect.class:297
#: frmPartSelect.class:303
msgid "/boot"
msgstr ""

#: frmPartSelect.class:303
#: frmPartSelect.class:309
msgid "/usr"
msgstr ""

#: frmPartSelect.class:309
#: frmPartSelect.class:315
msgid "/share"
msgstr ""

#: frmPartSelect.class:315
#: frmPartSelect.class:321
msgid "FileSystem"
msgstr ""

#: frmPartSelect.class:321
#: frmPartSelect.class:327
msgid "xfs"
msgstr ""

#: frmPartSelect.class:327
#: frmPartSelect.class:333
msgid "reiserfs"
msgstr ""

#: frmPartSelect.class:333
#: frmPartSelect.class:339
msgid "ext3"
msgstr ""

#: frmPartSelect.class:339
#: frmPartSelect.class:345
msgid "ext2"
msgstr ""

#: frmPartSelect.class:355
#: frmPartSelect.class:361
msgid "Click on select install drive"
msgstr ""

#: frmPartSelect.class:361
#: frmPartSelect.class:367
msgid "Right-click in Mount or FileSystem to set"
msgstr ""

#: frmPartSelect.class:395
#: frmPartSelect.class:401
msgid ""
"<ul>\n"
"<li>Left-click to (un)select drive(s) to install Vector Linux.</li>\n"
Expand Down
42 changes: 21 additions & 21 deletions .lang/frmPartSelect.pot
Original file line number Diff line number Diff line change
Expand Up @@ -14,87 +14,87 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: frmPartSelect.class:261
#: frmPartSelect.class:267
msgid "Mountpoints"
msgstr ""

#: frmPartSelect.class:267
#: frmPartSelect.class:273
msgid "/"
msgstr ""

#: frmPartSelect.class:273
#: frmPartSelect.class:279
msgid "/home"
msgstr ""

#: frmPartSelect.class:279
#: frmPartSelect.class:285
msgid "/var"
msgstr ""

#: frmPartSelect.class:285
#: frmPartSelect.class:291
msgid "/opt"
msgstr ""

#: frmPartSelect.class:291
#: frmPartSelect.class:297
msgid "/tmp"
msgstr ""

#: frmPartSelect.class:297
#: frmPartSelect.class:303
msgid "/boot"
msgstr ""

#: frmPartSelect.class:303
#: frmPartSelect.class:309
msgid "/usr"
msgstr ""

#: frmPartSelect.class:309
#: frmPartSelect.class:315
msgid "/share"
msgstr ""

#: frmPartSelect.class:315
#: frmPartSelect.class:321
msgid "FileSystem"
msgstr ""

#: frmPartSelect.class:321
#: frmPartSelect.class:327
msgid "xfs"
msgstr ""

#: frmPartSelect.class:327
#: frmPartSelect.class:333
msgid "reiserfs"
msgstr ""

#: frmPartSelect.class:333
#: frmPartSelect.class:339
msgid "ext3"
msgstr ""

#: frmPartSelect.class:339
#: frmPartSelect.class:345
msgid "ext2"
msgstr ""

#: frmPartSelect.class:347
#: frmPartSelect.class:353
msgid "Drives"
msgstr ""

#: frmPartSelect.class:355
#: frmPartSelect.class:361
msgid "Click on select install drive"
msgstr ""

#: frmPartSelect.class:361
#: frmPartSelect.class:367
msgid "Right-click in Mount or FileSystem to set"
msgstr ""

#: frmPartSelect.class:372
#: frmPartSelect.class:378
msgid "OK"
msgstr ""

#: frmPartSelect.class:379
#: frmPartSelect.class:385
msgid "Cancel"
msgstr ""

#: frmPartSelect.class:387
#: frmPartSelect.class:393
msgid "Partitions"
msgstr ""

#: frmPartSelect.class:395
#: frmPartSelect.class:401
msgid "<ul>\n<li>Left-click to (un)select drive(s) to install Vector Linux.</li>\n<li>Right-click on Linux partitions to pick mountpoint</li>\n<li>Left-click on other partitions to edit mountpoint</li>\n</ul>\n"
msgstr ""

4 changes: 2 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Title=VL-gui-installer
Startup=Main
Icon=vl_logo_icon2.png
Version=0.0.197
Version=0.0.227
Library=gb.qt
Library=gb.qt.ext
TabSize=3
Translate=1
ControlPublic=1
ExecPath=/home/moe/Desktop/vl-installer.gambas
ExecPath=/home/easuter/vinstall-ng.gambas
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="Sub"
SearchIn="Module"
CaseSensitive=True
SearchWord=False
SearchComment=False
Expand Down
69 changes: 56 additions & 13 deletions Functions.module
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

' ### SYSTEMWIDE FUNCTIONS ###

PUBLIC FUNCTION AutoUnits(capacity AS Long) AS String
' Return drive/partition size in nicer units as "value;unit" string:
PUBLIC FUNCTION AutoUnits(value AS Float) AS String
'Function that will automatically turn a generic size value into something human-readable (in multiples of bytes):
DIM temp AS Long

IF capacity < 1000 THEN ' Bytes:
RETURN Format$(capacity, "###,###,###,###") & ";B"
ELSE IF capacity < 1000000 THEN ' Kilobytes:
RETURN Format$(capacity / 1024, "###,###,###,###") & ";KB"
'gridDisk[m + 1,units].Text = "KB"
ELSE IF capacity < 1000000000 THEN ' Megabytes:
RETURN Format$(capacity / 1048576, "###,###,###,###") & ";MB"
'gridDisk[m + 1,units].Text = "MB"
ELSE IF capacity < 1000000000000 ' Gigabytes:
RETURN Format$(capacity / 1073741824, "####,###,###,###") & ";GB"
IF value < 1000 THEN ' Bytes:
RETURN value & " B"
ELSE IF value < 1000000 THEN ' Kilobytes:
RETURN Round(value / 1024, -2) & " KB"
ELSE IF value < 1000000000 THEN ' Megabytes:
RETURN Round(value / 1048576, -2) & " MB"
ELSE IF value < 1000000000000 ' Gigabytes:
RETURN Round(value / 1073741824, -2) & " GB"
ELSE 'Terabytes
RETURN Format$(capacity / 1099511627776, "####,###,###,###") & ";TB"
RETURN Round(value / 1099511627776, -2) & " TB"
END IF

END
Expand Down Expand Up @@ -215,6 +213,51 @@ CATCH ' Failed, usually due to already existing dirs:

END

PUBLIC FUNCTION getFreePartSpace(device AS String, filesystem AS String) AS Long
'Calculate the free space on a partition based on its filesystem, and then return the value
'This is basicaly a Gambas implementation of what GParted does for detecting free space on partitions in C++
DIM sTemp AS String
DIM sTemp2 AS String
DIM sFreeBlocks AS String
DIM sBlockSize AS String
DIM arrTemp AS NEW String[]
DIM iFreeBytes AS Long

device = Trim$(device)
filesystem = Trim$(filesystem)

'The array's index used ([x]) to get the free blocks and the block size was obtained by studying the ouput of the commands used below
IF filesystem = "Ext3" OR filesystem = "Ext2" THEN
SHELL "dumpe2fs -h " & device TO sTemp
sTemp = Trim$(sTemp)
arrTemp = Split(sTemp, Chr$(10))
sFreeBlocks = Trim$(Mid$(arrTemp[13], RInStr(arrTemp[13], Space$(1))))
sBlockSize = Trim$(Mid$(arrTemp[16], RInStr(arrTemp[16], Space$(1))))
iFreeBytes = CLng(sFreeBlocks) * CLng(sBlockSize)
ELSE IF filesystem = "XFS" THEN
SHELL "xfs_db -c 'sb 0' -c 'print blocksize' -c 'print fdblocks' -r " & device TO sTemp
sTemp = Trim$(sTemp)
arrTemp = Split(sTemp, Chr$(10))
sFreeBlocks = Trim$(Mid$(arrTemp[1], RInStr(arrTemp[1], Space$(1))))
sBlockSize = Trim$(Mid$(arrTemp[0], RInStr(arrTemp[0], Space$(1))))
iFreeBytes = CLng(sFreeBlocks) * CLng(sBlockSize)
ELSE IF filesystem = "ReiserFS" THEN
SHELL "debugreiserfs " & device TO sTemp
sTemp = Trim$(sTemp)
arrTemp = Split(sTemp, Chr$(10))
sFreeBlocks = Trim$(Mid$(arrTemp[6], RInStr(arrTemp[6], Space$(1))))
sBlockSize = Trim$(Mid$(arrTemp[5], RInStr(arrTemp[5], Space$(1))))
iFreeBytes = CLng(sFreeBlocks) * CLng(sBlockSize)
ELSE IF filesystem = "JFS" THEN
iFreeBytes = 0
ELSE
iFreeBytes = 0
ENDIF

RETURN iFreeBytes


END


PUBLIC FUNCTION CalcSwap(sysmem AS Long) AS Long
Expand Down
21 changes: 11 additions & 10 deletions Utils.module
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ DIM sTemp2 AS String
DIM pos AS Long
DIM n AS Long, m AS Long
DIM pcounter AS Long
DIM item AS Integer

' 4 debug:
IF Global.DebugMode = TRUE THEN
Expand All @@ -94,34 +93,36 @@ FOR n = 0 TO arrTemp1.Max
vPI.StartBlock = arrTemp2[2]
vPI.EndBlock = arrTemp2[3]
IF Right$(arrTemp2[4]) = "+" THEN
vPI.Blocks = Val(Left$(arrTemp2[4], Len(arrTemp2[4]) - 1))
vPI.Bytes = CLng(Val(Left$(arrTemp2[4], Len(arrTemp2[4]) - 1))) * 1024
ELSE
vPI.Blocks = Val(arrTemp2[4])
vPI.Bytes = CLng(Val(arrTemp2[4])) * 1024
ENDIF
vPI.ID = arrTemp2[5]
ELSE
vPI.Bootable = FALSE
vPI.StartBlock = arrTemp2[1]
vPI.EndBlock = arrTemp2[2]
IF Right$(arrTemp2[3]) = "+" THEN
vPI.Blocks = Val(Left$(arrTemp2[3], Len(arrTemp2[3]) - 1))
vPI.Bytes = CLng(Val(Left$(arrTemp2[3], Len(arrTemp2[3]) - 1))) * 1024
ELSE
vPI.Blocks = Val(arrTemp2[3])
vPI.Bytes = CLng(Val(arrTemp2[3])) * 1024
ENDIF
vPI.ID = arrTemp2[4]
ENDIF

IF Functions.getPartType(vPI.ID) = "Linux swap" THEN
vPI.FileSystem = "Swap"
ELSE IF Functions.getPartType(vPI.ID) = "Extended" THEN
IF Functions.getPartType(vPI.ID) = "Extended" THEN
vPI.FileSystem = "Extended"
ELSE
ELSE IF Functions.getPartType(vPI.ID) = "HPFS/NTFS" THEN
vPI.FileSystem = "NTFS"
ELSE
SHELL "disktype " & vPI.Device TO sTemp2
sTemp2 = Trim$(sTemp2)
arrTemp3 = Split(sTemp2, Chr$(10))
vPI.FileSystem = Trim$(Left$(arrTemp3[2], InStr(arrTemp3[2], Space$(1)))) 'after being trimmed, the filesystem data will be on line 3 of the buffer (index 2 of the array)
vPI.FileSystem = Trim$(Left$(arrTemp3[2], InStr(arrTemp3[2], Space$(1))))
ENDIF

vPI.FreeBytes = Functions.getFreePartSpace(vPI.Device, vPI.FileSystem)

Global.PartInfo.Push(vPI)
ELSE IF pos > 1 ' Parse a disk drive.
vDI = NEW cDiskInfo
Expand Down
Loading

0 comments on commit 5a5cc1c

Please sign in to comment.