1 /* $MirOS: contrib/code/jupp/path.h,v 1.11 2016/10/29 23:44:45 tg Exp $ */
3 * Directory and path functions
5 * (C) 1992 Joseph H. Allen
7 * This file is part of JOE (Joe's Own Editor)
14 #if defined(__MSDOS__) || defined(__DJGPP__) || defined(__EMX__) || \
15 defined(__CYGWIN__) || defined(_WIN32)
16 /*XXX check this for all platforms */
17 #define HAVE_BACKSLASH_PATHS 1
18 #define HAVE_DRIVE_LETTERS 1
20 #define HAVE_BACKSLASH_PATHS 0
21 #define HAVE_DRIVE_LETTERS 0
24 #if HAVE_BACKSLASH_PATHS
25 unsigned char *joesep PARAMS((unsigned char *path));
27 #define joesep(path) (path)
31 extern unsigned char has_JOERC, *get_JOERC;
32 void init_JOERC PARAMS((void));
35 #define get_JOERC JOERC
36 #define init_JOERC() /* nothing */
39 /* char *namprt(char *path);
40 * Return name part of a path. There is no name if the last character
43 * The name part of "/hello/there" is "there"
44 * The name part of "/hello/" is ""
45 * The name part if "/" is ""
47 unsigned char *namprt PARAMS((unsigned char *path));
48 unsigned char *namepart PARAMS((unsigned char *tmp, unsigned char *path))
49 ATTR_BOUNDED((__minbytes__,1,1024));
51 /* char *dirprt(char *path);
52 * Return directory and drive part of a path. I.E., everything to the
53 * left of the name part.
55 * The directory part of "/hello/there" is "/hello/"
56 * The directory part of "/hello/" is "/hello/"
57 * The directory part of "/" is "/"
59 * dirprt_ptr points to just beyond what dirprt returns.
61 unsigned char *dirprt PARAMS((unsigned char *path));
62 unsigned char *dirprt_ptr PARAMS((unsigned char *path));
64 /* char *begprt(char *path);
65 * Return the beginning part of a path.
67 * The beginning part of "/hello/there" is "/hello/"
68 * The beginning part of "/hello/" is "/"
69 * The beginning part of "/" is "/"
71 unsigned char *begprt PARAMS((unsigned char *path));
73 /* char *endprt(char *path);
74 * Return the ending part of a path.
76 * The ending part of "/hello/there" is "there"
77 * The ending part of "/hello/" is "hello/"
78 * The ending part of "/" is ""
80 unsigned char *endprt PARAMS((unsigned char *path));
82 /* int mkpath(char *path);
83 * Make sure path exists. If it doesn't, try to create it
85 * Returns 1 for error or 0 for success. The current directory
86 * and drive will be at the given path if successful, otherwise
87 * the drive and path will be elsewhere (not necessarily where they
88 * were before mkpath was called).
90 int mkpath PARAMS((unsigned char *path));
92 /* char *mktmp(char *, int *);
93 * Create an empty temporary file. The file name created is the string passed
94 * to this function postfixed with /joe.tmp.XXXXXX, where XXXXXX is some
95 * string six chars long which makes this file unique.
96 * If second argument is not NULL, fd is kept open and stored there.
98 unsigned char *mktmp PARAMS((unsigned char *where, int *fdp));
100 /* Change drive and directory */
103 /* int rmatch(char *pattern,char *string);
104 * Return true if string matches pattern
107 * * matches 0 or more charcters
108 * ? matches any 1 character
109 * [...] matches 1 character in set
110 * [^...] matches 1 character not in set
114 * any other matches self
116 * Ranges of characters may be specified in sets with 'A-B'
117 * '-' may be specified in sets by placing it at the ends
118 * '[' may be specified in sets by placing it first
120 int rmatch PARAMS((unsigned char *a, unsigned char *b));
121 int isreg PARAMS((unsigned char *s));
123 /* char **rexpnd(char *path,char *pattern);
124 * Generate array (see va.h) of file names from directory in 'path'
125 * which match the pattern 'pattern'
127 unsigned char **rexpnd PARAMS((unsigned char *word));
129 int chJpwd PARAMS((const unsigned char *path));
130 int chpwd PARAMS((const unsigned char *path));
131 unsigned char *pwd PARAMS((void));