Hi Tim,

I've had a quick look around for the "right" way to do this, and it seems there are 2 options: 1) Determine the max path length from a system macro, probably PATH_MAX in limits.h.
2) Use the unix system call pathconf() to get the max path length.

I think using a build time constant, as in 1, is preferable, however this macro is not defined on all platforms. On zOS, for example, only _POSIX_PATH_MAX is defined, and that is set to a paltry 256 (which is not the real max path length - pathconf() tells me it is 1024).

Perhaps to start with we can include /usr/include/linux/limits.h and use PATH_MAX for linux platforms (I'm assuming that file exists for linux distros in general here - perhaps someone can clarify this?) and on non-linux platforms fall back to a default of 1024. We can add other platforms in as we find the correct includes/macro definitions for them.

Regards,
Oliver


Tim Ellison (JIRA) wrote:
[classlib][luni] File path limit set to 1K chars for all file systems
---------------------------------------------------------------------

                 Key: HARMONY-6238
                 URL: https://issues.apache.org/jira/browse/HARMONY-6238
             Project: Harmony
          Issue Type: Sub-task
          Components: Classlib
    Affects Versions: 5.0M10
            Reporter: Tim Ellison


In Harmony's portlib  (modules/portlib/src/main/native/include/shared/hyport.h) 
 we set the maximum path length to 1024

/** HyMaxPath was chosen from unix MAXPATHLEN.  Override in platform
  * specific hyfile implementations if needed.
  */
#define HyMaxPath   1024

This causes some long file path operations to fail with an IOException on 
Harmony which do not fail on the RI.

Harmony should allow for file systems that handle longer paths.



--
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598. Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Reply via email to