On Thu, Aug 9, 2012 at 4:57 PM, Jon Sturm <jonimo...@gmail.com> wrote:

> On Thu, Aug 9, 2012 at 3:01 AM, Markus <li...@neuronenwerk.de> wrote:
> > Hi Pete,
> >
> > my answers became a bit longer than intended. Here's my 5 cent,
> > but generally, I'd leave the decision to you:
> >
> >> Now, this being said, I don't have that much of an issue bumping the
> >> limit, but 4K seems awfully large for a file path. Would 512 bytes
> >> be OK with you?
> >
> > I'm perfectly ok with that.
>
> You should use PATH_MAX from limits.h period. POSIX says it should be
> there on *nix and it is also there on windows, being equal to
> MAX_PATH+1 iirc. Its 4K on linux but its also what the the libc is
> going to assume so you know you won't run into issues. Hardcoding
> anything smaller is just asking for issues especially on sample code
> that people are likely to just Copy/Paste into their projects.
>


It's only defined if _POSIX_ is set in the limits.h from Visual Studio 2010
and then it's defined to 512 so I wouldn't be counting on it being defined
sensibly for Windows (where MAX_PATH+1 is your best bet... unless of course
you prefix all your paths with "\\?\" and make sure all '/'s are switched
to '\'s when the limit is somewhere close to 32768 characters*.  Yes, you
can create paths in Windows greater than MAX_PATH long, though it's a
tossup whether any given application can handle them.)

I'd do something like the following:

#include <limits.h>
#if defined(WIN32) && !defined(PATH_MAX)
#define PATH_MAX (MAX_PATH+1)
#endif

and use PATH_MAX like you suggested.

Orin.

*for native APIs.  The shell APIs have the MAX_PATH limitation which is
another can of worms...
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to