File::getVolumeLabel() returns String::empty


On Windows we can get volume label by File::getVolumeLabel(), but on Mac we cannot even if the file is on the mounted volume (and its name is shown in Finder.)

How about to make File("/Volumes/Foo/Bar").getVolumeLabel() return “Foo” as below?

const String juce_getVolumeLabel (const String& filenameOnVolume,
                                  int& volumeSerialNumber) throw()
    // There is no equivalent on Linux
    volumeSerialNumber = 0;
    return filenameOnVolumes
        .fromFirstOccurenceOf(T("/Volumes/"), false, false)
        .upToFirstOccurenceOf(T("/"), false, false);


Not a bad idea, though not much good for files on your normal disk. There’s a way to do it with getattrlist(), though I’ve never had time to experiment…