VirtualVolume Gotcha

| | Comments (1)

So I had cause to play around with VirtualVolumes for a project today, and I ran into a gotcha that you really should watch out for. It turns out that VirtualVolumes don't play nice with UTF-16 encodings, at least with regards to the file operations. I was getting file paths from the command line, which on NT-based versions of Windows will usually be in UTF-16. I was then using this information to create a folder hierarchy within a virtual volume, and couldn't figure out why my folders were never being created. What was even more strange was that the code worked when the paths were just string constants! Basically, this would work:
someVV.Child( "Test" ).CreateAsFolder
while this would fail:
someVV.Child( commandLineArg ).CreateAsFolder
It took quite a while to track down the fact that it was encodings related because the failure mode was to just silently not create the folder. No LastErrorCode, nothing. The only way I found out there was an issue was because a subsequent call to create a file was returning a nil stream back to me when it shouldn't have. Yikes!

Hopefully you won't run into this issue, but if you do, maybe this blog posting will pop into your mind and help out.

1 Comments

Good info, Aaron.

This is a great example of why having user comments for the Language Reference would be useful.

Sorry, had to beat that dead horse a bit. :)


Leave a comment

Disclaimer

I'm currently an employee of REAL Software. My blog is mine. The opinions represented in this blog are mine as well and may not represent my employer's opinions. All original material is copyrighted and property of the author.

REALbasic® is a registered trademark of REAL Software, Inc. REAL SQL Server™ and Lingua™ are pending trademarks of REAL Software, Inc. All rights reserved.