Hi Steve
UTFAT_PATH_IS_ROOT_REF is used as return value to distinguish this case by use when navigating through directories. It is not (usually) relevant to the user. Since error cases are negative, the best way to test for errors is thus:
if (result < UTFAT_SUCCESS)I tested your code and confirm that it doesn't move to the expected directory as you write. Before explaining why, it is best to know a couple of details about the directory object:
This has three objects which contain information about directories belonging to the directory object itself:
DISK_LOCATION root_disk_location; // reference to the root directory
DISK_LOCATION private_disk_location; // details of where the directory is physically located on the disk
DISK_LOCATION public_disk_location; // working information when searching for and manipulating directory contents
The
root_disk_location may be the root directory of the disk but it may also be the root directory of its use (restricted to certain sub-directory).
The
private_disk_location is supposed to be the location that the user is at (it can be anywhere below its root).
The
public_disk_location is a temporary entry which is used when operations are performed (its value is a sort of working area.
This means that one may expect the
private_disk_location changes when a directory is opened. This also happens when a directory is opened when the object is not yet valid. When using
utChangeDirectory() this is also correctly performed, but
utOpenDirectory() is also used to locate sub-directories without actually moving there so that remote operations can be performed.
This is maybe not logical and it would probably be best if the
utOpenDirectory() as used by the user were to move as
utChangeDirectory() does. I suppose that
utChangeDirectory() is more or less the
utOpenDirectory() as one would expect the latter to work.
It is however rather sensitive to change the
utOpenDirectory() so that it always moves because it then causes other uses to change in behavior. This means that I am going to have to study this more before making a decision as to its best solution.
A workaround for you is to use:
result = utChangeDirectory("/CONF", sdDirectory);instead of
result = utOpenDirectory("/CONF", sdDirectory);[this also returns
UTFAT_SUCCESS].
Only use the open to open the first directory when the object is not yet valid.Note that the navigation as performed by the DOS like interface and also FTP uses
utOpenDirectory() to see whether the location exists and this always moves there when the directory object is used for the first time. Then movement is then controlled by
utChangeDirectory(). This does work well but now I am wondering whether this is really the most logical method or is the functionality of
utChangeDirectory() more one would expect from
utOpenDirectory()?
Regards
Mark