Volumes
BlitzMax Forums/Brucey's Modules/Volumes
| ||
Hi Brucey. I've been using the volumes mod in NSS4 and love the simplicity of it. Now it may be totally unrelated to this module but I seem to be getting some problems from users that are running 64-bit Windows or foreign language versions of Windows. Basically when they first start my game it will create a save folder... GetUserDocumentsDir()+"/New Star Soccer 4/" For some users the game shuts down immediately and the save folder never gets created. So I'm trying to track down if it crashes before creating save location or after failing to create it. Basically once the save folder is created it stores a Settings.ini file in there. Without said file the game will crash. So I'm wondering if you or anyone else has successfully used the volumes locale on a 64-bit or a foreign windows machine? |
| ||
I think "foreign" is more likely to be an issue than 64bit (probably). Especially if there are non-ascii characters in the path. BlitzMax has failings when it comes to Unicode paths. I'm not sure how the path will appear if is has non-ascii characters in it, although Volumes should be able to retrieve it okay (it is calling the "W"-wide API, and using FromWString to store it before passing it back). Your issue may be with the BlitzMax file-handling code, which could be choking on the potential > 127 characters. Maybe :-) |
| ||
You are correct, Brucey- I use your Volumes mod too (thank you!) and yes, Cyrillic characters in someone's username will break it. So far I've only seen this break with Windows, but if it's a BlitzMax problem then I guess it would break on any OS. I would *love* a fix! ;) |
| ||
It may well be worth looking into this properly - for general file access. Looks like I may have found my "holiday" project :-) |
| ||
Hi Brucey, I also had a look at this mod and I found out that your windows routines to get the volumes are not perfect meaning that they don't get every volume connected to the pc. If you go to your Control Panel and then to "Administration Tools" (provided that you have the classical control panel style) and then to "Computer Management". An if you go there to the option "Disk Management" there you can remove the device letter and just mount the device in an empty folder (eg. on your desktop) like on linux (or mac?). And if this is the case your volume routines do not find this device. So I made a little research an quickly found a way to get this too. Besides my little demo shows that it can also handle mutiple mount points like to folders or a letter and a folder. I made a little demo to show you how it works. Maybe you can implement it in your module. Before I forget to mention it it uses the unicode winapi functions (ending with W) for all string things. |
| ||
Thanks Artemis :-) I'll have a look at fitting into the framework. Much appreciated! |
| ||
One thing it doesn't find are any of my network drives... (Q -> Z)... it is only showing A, C and D... so I guess I should implement some of what I have now, and some of this... |
| ||
Okay... this seems to work quite well now :Volumes : - A:\ (FAT) - 1mb - C:\ (NTFS) - 20500mb - D:\ () - 0mb - Q:\ () - 0mb - R:\ () - 0mb - S:\ () - 0mb Shared Folders - T:\ (PrlSF) - 12624mb Shared Folders - U:\ (PrlSF) - 12624mb Shared Folders - V:\ (PrlSF) - 12624mb Shared Folders - W:\ (PrlSF) - 12624mb Shared Folders - X:\ (PrlSF) - 196257mb Shared Folders - Y:\ (PrlSF) - 12624mb Shared Folders - Z:\ (PrlSF) - 12624mb A, C and D and found with your Volume search code, as above, and then I use GetLogicalDrives() to scan for driver letters, and add to the returned list if they aren't already in the list. This is the same list, but only showing "available" volumes Volumes : - A:\ (FAT) - 1mb - C:\ (NTFS) - 20500mb Shared Folders - T:\ (PrlSF) - 12624mb Shared Folders - U:\ (PrlSF) - 12624mb Shared Folders - V:\ (PrlSF) - 12624mb Shared Folders - W:\ (PrlSF) - 12624mb Shared Folders - X:\ (PrlSF) - 196257mb Shared Folders - Y:\ (PrlSF) - 12624mb Shared Folders - Z:\ (PrlSF) - 12624mb |
| ||
While I've been updating it for Unicode friendliness, I've also added three new Custom folder types, for Mac and Windows. Pictures (My Pictures), Movies (My Videos) and Music (My Music). Accessible via the GetCustomDir:string(dirType:int) function. See docs for dirType consts. |
| ||
I just looking for a possible solution for a my problem and I remembered your Volume module. Well - I have a new challenge for you Brucey! On my Ubuntu machine (localized in italian...) something is not working properly...[maybe this is already known!] This is a piece of your own code for vol_linux.bmx Method GetUserDesktopDir:String() Return getHome() + "/Desktop" ' <--- this is NORMAL in english End Method Method GetUserAppDir:String() Return getHome() End Method Method GetUserDocumentsDir:String() Return getHome() + "/Documents" ' <--- this is NORMAL in english End Method The italian version doesnt' recognize properly DESKTOP or DOCUMENTS - they are called respectely SCRIVANIA and DOCUMENTI... This is a test Import bah.volumes Local user_path:String=GetUserAppDir() Local docs_path:String=GetUserDocumentsDir() Local desktop_path:String=GetUserDesktopDir() Print "Desktop is "+desktop_path Print "User "+user_path Print "Docs "+docs_path Print Print "---- testing ----" Print WriteTest(desktop_path) WriteTest(user_path) WriteTest(docs_path) End Function WriteTest(where$) Print "Try to write a file to <"+where+">" Local fileID:TStream=WriteFile(where+"/test.txt") Local fileIN:TStream If fileID WriteLine fileID,"something..." CloseFile fileID Print "Try to read it!!!" fileIN=ReadFile(where+"/test.txt") If fileIN While Not Eof(fileIN) Print ReadLine(fileIN) Wend CloseFile fileIN End If Else Print "Error - file not found!" End If End Function I got this output Building untitled2 Compiling:untitled2.bmx flat assembler version 1.67.36 (32768 kilobytes memory) 3 passes, 4369 bytes. Linking:untitled2.debug Executing:untitled2.debug Desktop is /home/degac/Desktop User /home/degac Docs /home/degac/Documents ---- testing ---- Try to write a file to </home/degac/Desktop> Error - file not found! Try to write a file to </home/degac> Try to read it!!! something... Try to write a file to </home/degac/Documents> Error - file not found! Process complete The question is: Is there a way to retrieve the REAL NAME of these folders? And use where needed? |