home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <libc.h>
-
- char *str_dup(const char *src)
- {
- char *dst;
-
- dst = (char *)malloc(strlen(src) + 1);
- strcpy(dst, src);
- return dst;
- }
-
-
- int dircopy(char *dst, const char *src, int slash)
- /* copy directory part of file path */
- {
- int i, n;
-
- for (i = 0, n = -1; src[i]; i++) {
- dst[i] = src[i];
- if (src[i] == '/') n = i;
- }
- if (n >= 0) {
- if (slash) ++n;
- dst[n] = 0;
- }
- return n;
- }
-
-
- int getExtension(char const *fn)
- {
- int i, j;
-
- for (i = 0, j = -1; fn[i]; i++) {
- if (fn[i] == '.') j = i;
- else if (fn[i] == '/') j = -1;
- }
- if (j <= 0 || fn[j - 1] == '/')
- return 0; /* No Extension */
- return j + 1;
- }
-