Help needed converting C# function for use in B3D
Blitz3D Forums/Blitz3D Programming/Help needed converting C# function for use in B3D
| ||
Hi everyone, first I would like to say thanks to all of you that post on this forum as you have saved me pulling my hair out on quite a few occasions. I have no C# or any C experience & the code below just looks completely alien to me so any help in how to get it to work in B3D would be greatly appreciated. The thumbnail .tbn file is created via a hashing function. As explained earlier, the hash is based off the CRC32 of the pathname (plus filename) in lowercase. Files which are local are hashed using their drive letter. Remote files are hashed using the smb:// protocol designation and optional username and password. Examples 123456789 returns 0376e6e7 F:\Videos\Nosferatu.avi returns 2a6ec78d smb://user:pass@server/share/directory/ returns c5559f13 smb://user:pass@... returns 8ce36055 Remember: When hashing remote shares, use the path as displayed in the sources.xml file, which can include the username and password. When hashing directories for thumbnails, include the final slash. Sample Code The following code is written in C# and produces the same output as the XBMC hashing function. |
| ||
0x becomes $ in Blitz so 0x04C11DB7 would become $04C11DB7 << becomes shl ^ is the Xor operator and m_crc ^= xxx is nothing else than m_crc = m_crc ^ xxx, same for <<= someString.ToLower() is the same as lower(someString) and the looping over the byte array is nothing else than for i = 1 to len(someString) byte% = mid(someString,i,1) next the only thing where you potentially will get problems is the uint Blitz3d has no support for unsigned number types at all. so at worst you will be forced to introduce a "translation" there |
| ||
Thanks Dreamora, when i get back home i will try to get it to work. The reason i need to do it is because i have literally hundreds of thumbnails that i have manually downloaded & do not want to go through that again. I need to convert them because all my music & films were on the F: drive but due to a harddrive upgrade they have moved to the G: drive. Even if i get a majority converted that would save me many hours of searching the net again for replacements. I could attempt to learn C# but it seems a bit overkill just for a basically very small util (as well as learning how to do file handling etc). Once again thanks for pointing me in the right direction :) |