Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

dirtree-common.c

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  DIRTREE-COMMON.C                                                                    */
00003 /*                                                                                      */
00004 /*  Author: Samuel Seay                                                                 */
00005 /*  Description: Common functions between Dirtree files                                 */
00006 /*                                                                                      */
00007 /*  The contents of this file are subject to the Genesis3D Public License               */
00008 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00009 /*  compliance with the License. You may obtain a copy of the License at                */
00010 /*  http://www.genesis3d.com                                                            */
00011 /*                                                                                      */
00012 /*  Software distributed under the License is distributed on an "AS IS"                 */
00013 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00014 /*  the License for the specific language governing rights and limitations              */
00015 /*  under the License.                                                                  */
00016 /*                                                                                      */
00017 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00018 /*  Genesis3D Version 1.1 released November 15, 1999                                    */
00019 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved                            */
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

Generated on Tue Sep 30 12:35:37 2003 for GTestAndEngine by doxygen 1.3.2