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
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;
}
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~ 1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x 3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
Are you sure you got those numbers right? I.e., do you really want (in your second example) 3 GB plus 466 MB plus 821 MB plus 45 KB, i.e. 4 GB, 263 MB and 45 KB? And do you expect the two examples to add up to the same size in bytes? The first one is 3466840749 * 1024 bytes, which is around 3.23 terabytes, while the second one is 4570788864 bytes or around 4.26 gigabytes.
perhaps there should be a . in the last 6 digit figure but it doesn't matter they are only examples... thanks for the consideration though
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~ 1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x 3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
This is not possible. You could theoretically remove the SIZE parameter and turn all /S in to /K/N, but then you could no longer write 3 GB but had to write GB 3 or GB=3.
Another possibility is to keep the /S and turn size into /N/M. But then you could no longer tell which number belongs to which unit. For example you could write 1 MB 2 KB 3 GB but the program would make 1 GB, 2 MB and 3 KB of it.
Even now you can already use 1 KB MB GB and the program would use 1 GB because it checks for GB first and ignores the other switches if it finds GB.
In addtion your calculation is wrong. 3 GB are 3072 MB and not 3000 MB, so 3 GB + 466 MB is not 3466 MB but 3538 MB.
I know I didn't bother to times everything by 1024 I just copied the figure from the ctorrent client and then quickly tried to break it up for the second example...
So what you are saying is there is no way to alter this code to accept mkfile 3.4 gb for example without producing a totally new program source?
I need a b for bytes perhaps?
mkfile 3466840749 b
for example would create a file that size in bytes as far as AmigaDos is concerned, correct?
perhaps I need to look on Aminet
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~ 1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x 3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
Slayer wrote: @thomas So what you are saying is there is no way to alter this code to accept mkfile 3.4 gb for example without producing a totally new program source?
Correct. Of course it can be done, but not using ReadArgs(), and then it would hardly be an Amiga program any more, but just another generic *N?X C program. And coding the args parsing would be maybe 90 percent of the program anyway (once you know what size the user wants the file, it is created "with a snap of your fingers"). Which is part of the reason the program can be done so elegantly with ReadArgs().
Quote:
I need a b for bytes perhaps?
mkfile 3466840749 b
for example would create a file that size in bytes as far as AmigaDos is concerned, correct?
That should be possible within the current framework.
So what you are saying is there is no way to alter this code to accept mkfile 3.4 gb for example without producing a totally new program source?
ReadArgs() doesn't support floating point numbers and neither does my program so this will not work.
I could rewrite the template as: FILE/A,SIZE/A,TB/S,GB/S,MB/S,KB/S
In this case I could use my own code for converting SIZE into a number and also handle larger numbers correctly. ATM it can only handle numbers up to 2^32-1 AFAIK.
Alternately I've thought of using: FILE/A,SIZE/M
This way you could type f.e.: mkfile filename.ext 50gb 100kb 128b
or just: mkfile filename.ext 50g 100k 128
Quote:
I need a b for bytes perhaps?
mkfile 3466840749 b
for example would create a file that size in bytes as far as AmigaDos is concerned, correct?
You don't need a switch for bytes. If no switch is given the size is assumed to be in bytes.
You don't need a switch for bytes. If no switch is given the size is assumed to be in bytes.
I will test this later but I think this is all I needed to know... how perculiar... thanks!
and thank you for everyone else that had some input... always very much appreciated!
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~ 1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x 3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x