In certain parts of my code the results from JUCE(like FileChooser, or dropFiles) when the user drops a drive(instead of a folder or file) will give me a FullPathname of something like E: (no trailing )
Then if I try to getVolumeLabel it fails, below is the fix…
String getDriveFromPath (String path)
{
if (path.length()==2 && path[1] == ':') // current path is something like E:
path=path+'\\'; // add a trailing \ for PathStripToRoot to chomp on
else
path = (path + " ").dropLastCharacters(1); // (mess with the string to make sure it's not sharing its internal storage)
WCHAR* p = const_cast <WCHAR*> (path.toWideCharPointer());
if (PathStripToRoot (p))
return String ((const WCHAR*) p);
return path;
}
