Hi, just creating a simple too to get version strings, when there is a "buggy" I load the first 64K of the file and then try to fiind '$VER', just want to know which "method" can be the best/fastest.
int32 buf_len; uint8 *buf = IExec->AllocVecTags(65535, AVT_ClearWithValue,0, TAG_DONE); res = FALSE; n = 0; if(buf) { BPTR fhBinFile = IDOS->Open(name, MODE_OLDFILE); //if(!fhBinFile) { buf_len = IDOS->Read(fhBinFile, buf, 65535); // only on first 64K of file buf_len-=3; while(buf_len--) { ...
Then for checking for '$VER' I manage to create 3 different modes, they seem to work fine, but if someone finds a problem using such modes I'm open to all possible suggestions. (BTW is it worth to use AVT_ClearWithValue,0?)
if( !(*(buf+n)^0x24) && !(*(buf+n+1)^0x56) && !(*(buf+n+2)^0x45) && !(*(buf+n+3)^0x52) ) { // '$VER' = 0x24564552 if(IUtility->Strnicmp((STRPTR)(buf+n),"$VER",4) == 0) { int32 foo = *(buf+n) << 24 | *(buf+n+1) << 16 | *(buf+n+2) << 8 | *(buf+n+3); if(foo == 0x24564552 ) { // '$VER' = 0x24564552
TIA
@jabirulo
Don't know about your actual intentions here but personally I'd use GetSegListInfo() to obtain the version string, instead of reading data from the file directly. To do this you need to LoadSeg() from your file, then use GetSegListInfo() to obtain the value of the GSLI_VersionString tag (possibly also GSLI_ResidentVersionString as a fallback), and UnLoadSeg() when you're finished.
AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2
Already doing thath first, but some software has "weird" $VER strings (empty) and thus GetSegListInfo() fails. Example: metadata.library (os4depot):
#version ram:MetadataLibrary/libs/metadata.library file full
$ver:
#getversion ram:MetadataLibrary/libs/metadata.library
metadata.library 1.1 (20.5.2016)
Uploaded my unfished GetVersion here: http://jabirulo.site90.com/temp/GetVersionRC.7zip
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P
I had old mistake still in metadata.library which I've done in all my software searching for the version tag using string comparison and static "$ver" string. That confuses every piece of software which is searching for version tags. Nowadays I'm using GetSegListInfo() everywhere. I uploaded a fixed version of the metadata.libary to os4depot a moment ago.
If you want to create your own routine don't use string comparison but compare data byte by byte to avoid the mentioned issue.
What I do in my little getVersion tool:
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P