[MPlayer-cvslog] r32731 - in trunk: path.c path.h

Clément Bœsch ubitux at gmail.com
Sun Dec 26 11:08:19 CET 2010


On Sun, Dec 26, 2010 at 10:57:19AM +0100, Reimar Döffinger wrote:
> On 26 dec 2010, at 09:22, KO Myung-Hun <komh78 at gmail.com> wrote:
> > Clément Bœsch wrote:
> >> On Sun, Dec 26, 2010 at 02:12:19AM +0900, KO Myung-Hun wrote:
> >>> Hi/2.
> >>> 
> >>> cboesch wrote:
> >>>> Author: cboesch
> >>>> Date: Sat Dec 25 00:09:08 2010
> >>>> New Revision: 32731
> >>>> 
> >>>> Log:
> >>>> Add mp_path_is_absolute function.
> >>>> 
> >>>> Modified:
> >>>>   trunk/path.c
> >>>>   trunk/path.h
> >>>> 
> >>>> Modified: trunk/path.c
> >>>> ==============================================================================
> >>>> --- trunk/path.c    Sat Dec 25 00:05:49 2010    (r32730)
> >>>> +++ trunk/path.c    Sat Dec 25 00:09:08 2010    (r32731)
> >>>> @@ -233,3 +233,15 @@ char *mp_dirname(const char *path)
> >>>>     dirname[len] = '\0';
> >>>>     return dirname;
> >>>> }
> >>>> +
> >>>> +/**
> >>>> + * @brief Indicates weither the path is absolute or not.
> >>>> + */
> >>>> +int mp_path_is_absolute(const char *path)
> >>>> +{
> >>>> +#if HAVE_DOS_PATHS
> >>>> +    return path[0] && path[1] == ':';
> >>>> +#else
> >>>> +    return path[0] == '/';
> >>>> +#endif
> >>>> +}
> >>>> 
> >>> 
> >>> You should consider the case that path[0] is '/' or '\\' as well in
> >>> HAVE_DOS_PATHS
> >>> 
> >> 
> >> Mmmh ok, I'll fix that. But I wonder how opendir() will behave in those
> >> cases (I don't have any windows machine to test).
> >> 
> > 
> > It uses a current drive.
> 
> Which is what makes this complicated, /something and \something are
> _not_ absolute paths on windows, they do depend on the current
> directory.
> Neither is c: btw., only c:/ and c:\ and \\something are absolute paths.

I created this function in order to handle if the path could be used as a
relative path (concatened with another base path), so it should handle the
'/' and '\\' as well. Same goes for "c:" only. Eiterway, path will be
concatened. So maybe "absolute" is not the correct word to use. What do
you propose?

> So in case you ever wonder again why Windows has so many security
> issues, that is it. It has almost as many special cases as the English
> language, making it near impossible to get everything right.
> _______________________________________________
> MPlayer-cvslog mailing list
> MPlayer-cvslog at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/mplayer-cvslog

-- 
Clément B.
Not sent from a jesusPhone.


More information about the MPlayer-cvslog mailing list