mkfile is a nifty little program that creates a blank file of the specified size... I just want to slightly change it...
I should be able to compile it myself...
Any would be coders out there mind changing this code just slightly to cater to weird numbers? I could theorectically create a file of all of the individual components and then join them all but how hard would it be to change the code so it would do this?
mkfile "GBCPC V8 Full.rar" 3466840749 kb
OR
mkfile "GBCPC V8 Full.rar" 3 gb 466 mb 840749 kb
I might contact the uploader if all else fails but didn't think he would mind if we did a bit of brain storming here on Amigans
thanks goes to those that ponder this
#include <dos/dos.h>
#include <proto/dos.h>
#define PROGNAME "mkfile"
#define TEMPLATE "FILE/A,SIZE/N/A,TB/S,GB/S,MB/S,KB/S"
int main () {
struct {
const char *filename;
int32 *filesize;
uint32 terabytes;
uint32 gigabytes;
uint32 megabytes;
uint32 kilobytes;
} args = {0};
void *rd_args;
int rc = 20;
BPTR file = ZERO;
int64 filesize;
rd_args = IDOS->ReadArgs(TEMPLATE, (LONG *)&args, NULL);
if (!rd_args) {
IDOS->PrintFault(IDOS->IoErr(), PROGNAME);
return rc;
}
if (*args.filesize < 0 ||
(args.terabytes && *args.filesize > 0x7fffff)) {
IDOS->PrintFault(ERROR_BAD_NUMBER, PROGNAME);
goto out;
}
if (args.terabytes) {
filesize = ((int64)*args.filesize) << 40;
} else if (args.gigabytes) {
filesize = ((int64)*args.filesize) << 30;
} else if (args.megabytes) {
filesize = ((int64)*args.filesize) << 20;
} else if (args.kilobytes) {
filesize = ((int64)*args.filesize) << 10;
} else {
filesize = *args.filesize;
}
file = IDOS->Open(args.filename, MODE_OLDFILE);
if (!file) {
file = IDOS->Open(args.filename, MODE_NEWFILE);
}
if (file) {
if (IDOS->ChangeFileSize(file, filesize, OFFSET_BEGINNING)) {
rc = 0;
}
IDOS->Close(file);
}
if (rc) {
IDOS->PrintFault(IDOS->IoErr(), args.filename);
}
out:
IDOS->FreeArgs(rd_args);
return rc;
}