Blame gl/filename.h

Packit a4aae4
/* Basic filename support macros.
Packit a4aae4
   Copyright (C) 2001-2004, 2007-2017 Free Software Foundation, Inc.
Packit a4aae4
Packit a4aae4
   This program is free software: you can redistribute it and/or modify
Packit a4aae4
   it under the terms of the GNU Lesser General Public License as published by
Packit a4aae4
   the Free Software Foundation; either version 3 of the License, or
Packit a4aae4
   (at your option) any later version.
Packit a4aae4
Packit a4aae4
   This program is distributed in the hope that it will be useful,
Packit a4aae4
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a4aae4
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit a4aae4
   GNU Lesser General Public License for more details.
Packit a4aae4
Packit a4aae4
   You should have received a copy of the GNU Lesser General Public License
Packit a4aae4
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit a4aae4
Packit a4aae4
#ifndef _FILENAME_H
Packit a4aae4
#define _FILENAME_H
Packit a4aae4
Packit a4aae4
#ifdef __cplusplus
Packit a4aae4
extern "C" {
Packit a4aae4
#endif
Packit a4aae4
Packit a4aae4
Packit a4aae4
/* Pathname support.
Packit a4aae4
   ISSLASH(C)           tests whether C is a directory separator character.
Packit a4aae4
   IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
Packit a4aae4
                        it may be concatenated to a directory pathname.
Packit a4aae4
   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
Packit a4aae4
 */
Packit a4aae4
#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
Packit a4aae4
  /* Native Windows, Cygwin, OS/2, DOS */
Packit a4aae4
# define ISSLASH(C) ((C) == '/' || (C) == '\\')
Packit a4aae4
# define HAS_DEVICE(P) \
Packit a4aae4
    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
Packit a4aae4
     && (P)[1] == ':')
Packit a4aae4
# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
Packit a4aae4
# define IS_PATH_WITH_DIR(P) \
Packit a4aae4
    (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
Packit a4aae4
# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
Packit a4aae4
#else
Packit a4aae4
  /* Unix */
Packit a4aae4
# define ISSLASH(C) ((C) == '/')
Packit a4aae4
# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
Packit a4aae4
# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
Packit a4aae4
# define FILE_SYSTEM_PREFIX_LEN(P) 0
Packit a4aae4
#endif
Packit a4aae4
Packit a4aae4
Packit a4aae4
#ifdef __cplusplus
Packit a4aae4
}
Packit a4aae4
#endif
Packit a4aae4
Packit a4aae4
#endif /* _FILENAME_H */