Priyank
Priyank

Reputation: 145

Boost API to check if the directory path is on network in c++

I am writing some files using my application in c++, when I save them on network drive using std::io operation the application freezes till the file is completely written, and the process is taking time whereas on local drive it does the operation very quickly.

Is there any way we can identify directory path is on a Network drive(Mapped/Non-mapped) or not? so that i can issue a warning to user, and later break the operation to save it locally first then move the file to network in background.

PS : comparing "\\" is not an option since the drive may be mapped.

Upvotes: 2

Views: 978

Answers (1)

Yury Schkatula
Yury Schkatula

Reputation: 5369

Sorry for potential off-topic polemic but it seems you're on the wrong way. Any file operation can be slow, regardless the local/remote nature of the storage.

  • Fragmentation makes any disk operation slower (regardless read/write)
  • NTFS volumes can be split into several physical drives (some of them can be slower than another)
  • Any hard drive can take arbitrary long timeout if he's trying to read damaged area (bad blocks etc.)
  • Even good drive can spend noticeable time if the file is huge (making non-convenient user experience)

So it's more productive to move your disk IO to another thread to provide end-users with non-freezing UI.

Upvotes: 2

Related Questions