[Development] QStorageInfo

Rutledge Shawn Shawn.Rutledge at digia.com
Thu Aug 28 08:57:30 CEST 2014


On 28 Aug 2014, at 8:06 AM, Lorn Potter wrote:

> On 27/08/2014 9:56 pm, Bo Thorsen wrote:
>> Den 27-08-2014 10:40, Knoll Lars skrev:
>>> I agree that there are many complex corner cases where we can’t exactly
>>> know. But let’s not forget about the common case, where we actually can
>>> determine whether the file system is local or not. I think we all agree
>>> that it’s very helpful to many applications to know this. So saying we
>>> don’t help at all here because we can’t solve 100% of the problems is
>>> wrong and not what Qt is about.
>>> 
>>> So I am all for a tri/quad state here. Local, Remote & Other/Unknown. And
>>> maybe a Special for things such as procfs. Let’s be conservative with it
>>> and rather have a bit too much in Other/Unknown, but let’s also help
>>> people that need the information and give the right answer for the common
>>> cases.
>>> 
>>> So I’d say let’s add the enum and getters for it. We can have a default
>>> implementation that returns Unknown, and then reimplement it on each
>>> platform to do something more sensible.
>> 
>> I haven't seen anyone ask for info on what type a drive is, if it's not
>> local. André did, but when he explained later, he said that what they
>> check for is if it's a local drive or not.
>> 
>> The two use cases I saw in this thread were both of the type where they
>> checked that storage was on a local drive because something else would
>> be too slow. This assumption might be wrong in some cases anyway, so I
>> hope they only warn that it might be bad.
>> 
>>  From following the discussion, it sounds like what actually be needed
>> is a isLocal() method that return yes, no or unknown/somethingelse.
>> That's a bit simpler and has the advantage that we won't have to expand
>> on it to be exact when people come up with weird new hybrid solutions.
> 
> I agree something simpler like this would be better. As mentioned 
> previously, detecting remote drives on all platforms is not fool proof, 
> and hard to implement and I am not sure it's worth trying to get all the 
> niche cases fixed.
> 
> Heck just figuring out if its a usb drive is not 100% for sure.

But isLocal is the wrong name for something that isn't a bool, and also implies that local drives are normal or preferred (which is a matter of current fashion, while the future is debatable).  If we want an enum, maybe we'd better go back to calling it some sort of type flag, but only have 3 possible values for now?  It is more extensible: we can add new flags whenever we are sure that they can be set reliably on all platforms.  And ORing them is more extensible than making them mutually exclusive, because we don't know what flags we will add later.  So let's have zero be the "unknown", and the type of this property should be QFlags. What should its name be?




More information about the Development mailing list