Inconsistency between "exist" function and "h5info" with long file path

When a file path greater than 260 characters is specified, the "exist" function returns a positive value between 1 to 7. However, the "h5info" function is not able to read the file. Something like below fails because of this inconsistency:
if( exist(FILEPATH) )
h5info(FILEPATH)
end
Why does this inconsistency exist in MATLAB?

 Accepted Answer

There is an inconsistency because "exist" is implemented by MathWorks and "h5info" is implemented on top of the third-party HDF5 library. MATLAB uses the Unicode versions of the Windows File System APIs which have a path limit of 32,767 characters.  The HDF5 library uses non-Unicode Windows APIs that have the path limit of 260 characters.
In order to avoid this situation, always have the path length for any file less than 260 characters.

More Answers (0)

Products

Release

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!