2 * Directory and path functions
4 * (C) 1992 Joseph H. Allen
6 * This file is part of JOE (Joe's Own Editor)
12 __IDSTRING(rcsid_path_h, "$MirOS: contrib/code/jupp/path.h,v 1.13 2017/12/02 17:00:49 tg Exp $");
15 #if defined(__MSDOS__) || defined(__DJGPP__) || defined(__EMX__) || \
16 defined(__CYGWIN__) || defined(_WIN32)
17 /*XXX check this for all platforms */
18 #define HAVE_BACKSLASH_PATHS 1
19 #define HAVE_DRIVE_LETTERS 1
21 #define HAVE_BACKSLASH_PATHS 0
22 #define HAVE_DRIVE_LETTERS 0
25 #if HAVE_BACKSLASH_PATHS
26 unsigned char *joesep PARAMS((unsigned char *path));
28 #define joesep(path) (path)
32 extern unsigned char has_JOERC, *get_JOERC;
33 void init_JOERC PARAMS((void));
36 #define get_JOERC JOERC
37 #define init_JOERC() /* nothing */
40 /* char *namprt(char *path);
41 * Return name part of a path. There is no name if the last character
44 * The name part of "/hello/there" is "there"
45 * The name part of "/hello/" is ""
46 * The name part if "/" is ""
48 unsigned char *namprt PARAMS((unsigned char *path));
49 unsigned char *namepart PARAMS((unsigned char *tmp, unsigned char *path))
50 ATTR_BOUNDED((__minbytes__,1,1024));
52 /* char *dirprt(char *path);
53 * Return directory and drive part of a path. I.E., everything to the
54 * left of the name part.
56 * The directory part of "/hello/there" is "/hello/"
57 * The directory part of "/hello/" is "/hello/"
58 * The directory part of "/" is "/"
60 * dirprt_ptr points to just beyond what dirprt returns.
62 unsigned char *dirprt PARAMS((unsigned char *path));
63 unsigned char *dirprt_ptr PARAMS((unsigned char *path));
65 /* char *begprt(char *path);
66 * Return the beginning part of a path.
68 * The beginning part of "/hello/there" is "/hello/"
69 * The beginning part of "/hello/" is "/"
70 * The beginning part of "/" is "/"
72 unsigned char *begprt PARAMS((unsigned char *path));
74 /* char *endprt(char *path);
75 * Return the ending part of a path.
77 * The ending part of "/hello/there" is "there"
78 * The ending part of "/hello/" is "hello/"
79 * The ending part of "/" is ""
81 unsigned char *endprt PARAMS((unsigned char *path));
83 /* int mkpath(char *path);
84 * Make sure path exists. If it doesn't, try to create it
86 * Returns 1 for error or 0 for success. The current directory
87 * and drive will be at the given path if successful, otherwise
88 * the drive and path will be elsewhere (not necessarily where they
89 * were before mkpath was called).
91 int mkpath PARAMS((unsigned char *path));
93 /* char *mktmp(char *, int *);
94 * Create an empty temporary file. The file name created is the string passed
95 * to this function postfixed with /joe.tmp.XXXXXX, where XXXXXX is some
96 * string six chars long which makes this file unique.
97 * If second argument is not NULL, fd is kept open and stored there.
99 unsigned char *mktmp PARAMS((unsigned char *where, int *fdp));
101 /* Change drive and directory */
104 /* int rmatch(char *pattern,char *string);
105 * Return true if string matches pattern
108 * * matches 0 or more charcters
109 * ? matches any 1 character
110 * [...] matches 1 character in set
111 * [^...] matches 1 character not in set
115 * any other matches self
117 * Ranges of characters may be specified in sets with 'A-B'
118 * '-' may be specified in sets by placing it at the ends
119 * '[' may be specified in sets by placing it first
121 int rmatch PARAMS((unsigned char *a, unsigned char *b));
122 int isreg PARAMS((unsigned char *s));
124 /* char **rexpnd(char *path,char *pattern);
125 * Generate array (see va.h) of file names from directory in 'path'
126 * which match the pattern 'pattern'
128 unsigned char **rexpnd PARAMS((unsigned char *word));
130 int chJpwd PARAMS((const unsigned char *path));
131 int chpwd PARAMS((const unsigned char *path));
132 unsigned char *pwd PARAMS((void));