Game Development Community

TGB and free and total disk space

by Alexandre Ribeiro de Sa · in Torque Game Builder · 10/17/2007 (12:59 pm) · 3 replies

Hi, I have a small question about TGB Scripting, there any way to get the free and total disk space?


Thanks!
Alexandre

#1
10/18/2007 (5:26 am)
As I know there is not such possibility in TGB, but are you shure you really need to know a disk spase inside your game?

May be it will be enougth to check a disk space during an installation. There are many installation programs which could be useful for this purpose.
#2
10/18/2007 (1:40 pm)
Hi Dmitriy, yes, I need this inside... But ok, I made a small code to do it :)

here the code, sory just for windows -_-'

inside consoleFunctions.cc
#include <windows.h>

.
.
.
.
.

ConsoleFunction( DiskManagerFreeSpace, S32, 2, 2, "DiskManagerFreeSpace( \"c:\" )")
{
	unsigned __int64 returnValue;
	if( !GetDiskFreeSpaceExA(
		argv[1],								// directory name
		0,										// bytes available to caller
		0,										// bytes on disk
		(PULARGE_INTEGER)&returnValue) )		// free bytes on disk
		return 0;

	return( unsigned int( returnValue/(1048576) ) );
}

ConsoleFunction( DiskManagerTotalSpace, S32, 2, 2, "DiskManagerTotalSpace( \"c:\" )")
{
	unsigned __int64 returnValue;
	if( !GetDiskFreeSpaceExA(
		argv[1],								// directory name
		0,										// bytes available to caller
		(PULARGE_INTEGER)&returnValue,			// bytes on disk
		0) )									// free bytes on disk
		return 0;

	return( unsigned int( returnValue/(1048576) ) );
}
#3
10/18/2007 (9:54 pm)
Good job Alexandre.
I've supposed you are own the indie license only (as me) and do not able to change a source.