00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <assert.h>
00024 #include <string.h>
00025
00026 #include "ram.h"
00027 #include "dirtree-common.h"
00028
00029 char * DuplicateString(const char *String)
00030 {
00031 int Length;
00032 char * NewString;
00033
00034 Length = strlen(String) + 1;
00035 NewString = geRam_Allocate(Length);
00036 if (NewString)
00037 memcpy(NewString, String, Length);
00038 return NewString;
00039 }
00040
00041 const char *GetNextDir(const char *Path, char *Buff)
00042 {
00043 while (*Path && *Path != '\\')
00044 *Buff++ = *Path++;
00045 *Buff = '\0';
00046
00047 if (*Path == '\\')
00048 Path++;
00049
00050 return Path;
00051 }
00052
00053 geBoolean MatchPattern(const char *Source, const char *Pattern)
00054 {
00055 assert(Source);
00056 assert(Pattern);
00057
00058 switch (*Pattern)
00059 {
00060 case '\0':
00061 if (*Source)
00062 return GE_FALSE;
00063 break;
00064
00065 case '*':
00066 if (*(Pattern + 1) != '\0')
00067 {
00068 Pattern++;
00069 while (*Source)
00070 {
00071 if (MatchPattern(Source, Pattern) == GE_TRUE)
00072 return GE_TRUE;
00073 Source++;
00074 }
00075 return GE_FALSE;
00076 }
00077 break;
00078
00079 case '?':
00080 return MatchPattern(Source + 1, Pattern + 1);
00081
00082 default:
00083 if (*Source == *Pattern)
00084 return MatchPattern(Source + 1, Pattern + 1);
00085 else
00086 return GE_FALSE;
00087 }
00088
00089 return GE_TRUE;
00090 }
00091
00092 geBoolean PathHasDir(const char *Path)
00093 {
00094 if (strchr(Path, '\\'))
00095 return GE_TRUE;
00096
00097 return GE_FALSE;
00098 }
00099
00100 #ifdef DEBUG
00101 void indent(int i)
00102 {
00103 while (i--)
00104 printf(" ");
00105 }
00106 #endif