Blame lib/filename.h

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