OK, it seems the things are a bit more clear now.
1. External drive. Some file on it.
QStorageInfo(pathToFile).rootPath() returns a valid path. I save it for
the further usage (SRP).
2. Disconnect the drive, restart app.
QStorageInfo(SRP).isValid() returns false. (as expected)
3. Connect the drive.
QStorageInfo(SRP).isValid() starts returning true, but it's rootPath()
method starts returning "/" instead of SRP value!
I.e. it starts pointing to a system root drive! After the few seconds
QStorageInfo(SRP) starts pointing again to that external drive because
its rootPath() method starts returning SRP value.
Looks like a bug.
On 7/19/2017 10:51 AM, Alexander Dyagilev wrote:
Hello,
|Mac OS X El Capitan 10.11.6|.
I have an external drive. In my app, I monitor for it to be connected
to PC. I use |QStorageInfo| for this providing it with the drive's
root path.
On that drive I have a file with a known path to it. I need to check
if the file exists once the drive is connected.
The problem is that once I connect the drive, |QStorageInfo| starts to
return |true| for both |isValid| and |isReady|, but |QFile::exists|
returns |false| while the file is really exists on the drive. It keeps
returning |false| for a few seconds. After that seconds it starts
returning |true|.
Is it a bug in Qt/MAC or am I missing something?
Qt 5.9.1.
P.S. It works fine on Windows 10.
Code Example.
|QStorageInfos(storageRootPath);if(s.isValid()&&s.isReady()){autoexists
=QFile::exists(pathToFile);// getting false here for a few seconds}|
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest