Blame lib/filename.h

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