Link to home
Start Free TrialLog in
Avatar of pepr
pepr

asked on

What Windows API to be used to test host and mount point for existence?

I do have UNC path like \\host\mountpoint\subdir\subdirB\etc. I want to implement a function that creates all directories along the path if they do not exist. I need to detect whether the host and the mount point exists. What API should be used? (I am using C++, low level is acceptable.)

My previous naive approach did not take UNC paths into account. I did split the path to the disk name and the list of subdirectories. Then I went from the root of the disk and used _stat() function to test whether the item exists and whether it is a subdirectory. Later, I tried to modify the source to accept UNC paths; however, the _stat() fails for \\host and \\host\mountpoint. Now I have to modify my exists() and isdir() functions so that they do not use the _stat() function.

I have already implemented the splitunc() fuction that returns the pair of (unc, rest) paths (the Python language heritage). I need to modify my exists() so that it says whether the \\host exists or not and whether the \\host\mountpoint exists or not.

Is it reasonable to say that \\host is never a file nor the directory, and \\host\mountpoint (if exists) is never a file but can be treated as directory?

Thanks for your time and experience,
  Petr
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pepr
pepr

ASKER

Thanks jkr. The GetFileAttributes() was the answer for what I needed.