1 ///////////////////////////////////////////////////////////////////////////////
2 // $Source: x:/prj/tech/libsrc/cpptools/RCS/fnamutil.h $
4 // $Date: 1997/08/13 19:01:13 $
7 // File name string manipulation functions
9 // (c) Copyright 1995-1996 Tom Leonard. All Rights Reserved. Unlimited license granted to Looking Glass Technologies Inc.
15 #if defined(__SC__) || defined(__RCC__)
20 #error "Need C versions of fnamutil"
25 enum eFileCondenseCase
35 // Combine a path and a (possibly absolute) file spec into a new, reduced path
36 // (e.g. AddFileSpec("c:\\foo\\bar", "..\\include\\bar.h")
37 // becomes ("c:\\foo\\include\\bar.h)
38 // and AddFileSpec("c:\\foo\\bar", "d:\\bar.h")
39 // becomes ("d:\\bar.h))
41 // Returns combined path in malloc'd string caller must free
42 // Returns: FALSE if invalid path (i.e., not all dots were removed,
43 // or illegal relative path)
45 BOOL __stdcall __CPPTOOLSAPI
AddFileSpec(const char * pszPath
, const char * pszFileSpec
, char ** ppszOut
);
48 // Compute a relative path between this path and a target
50 // Takes: the anchor, the goal, The output
51 // The result is the path relative to this to get to the target,
52 // or else is the full path to the target
54 BOOL __stdcall __CPPTOOLSAPI
ComputeAnchoredPath(const char * pszAnchorPath
, const char * pszTargetPathIn
, char ** ppszOut
);
59 BOOL __stdcall __CPPTOOLSAPI
IsValidFileSpec(const char * pszFileSpec
);
60 BOOL __stdcall __CPPTOOLSAPI
IsValidFilePath(const char * pszFilePath
);
63 // Get a full path, return FALSE if invalid
65 BOOL __stdcall __CPPTOOLSAPI
GetFullPath(const char * pszPath
, char ** ppszOut
);
69 // In-place lexical dot reduction (e.g., "\\a\\b\\..\\c" -> "a\\c")
71 // Takes: File path or file name
72 // Returns: FALSE if invalid path (i.e., not all dots were removed
73 // or illegal relative path)
75 BOOL __stdcall __CPPTOOLSAPI
ReduceDots(char *psz
);
81 #define _IsSlash(c) (c == '\\')
84 // Return true if this path is a simple component (i.e., is just a file root & ext)
87 inline BOOL
IsPathSimpleComponent(const char *p
)
89 return (p
&& *p
&& *(p
+1) != ':' && !strchr(p
, '\\'));
94 // Return true if this path is full (i.e., has a drive and root)
96 inline BOOL
IsFullPath(const char *p
)
98 // Check for start of domain or x:\...
102 return _IsSlash(*++p
);
105 return _IsSlash(*++p
);
111 // Return true if this a relative path (no root, no drive, no domain)
113 inline BOOL
IsRelativePath(const char *p
)
115 return (!*p
|| (!_IsSlash(*p
) && *(p
+1) != ':'));
119 // Return true if this a drive relative path (no root, but perhaps a drive)
121 inline BOOL
IsDriveRelativePath(const char *p
)
132 return !_IsSlash(*++p
);
135 char *GetCondensePathStr(
136 const char *pOriginalPath
,
138 unsigned nCondenseToLen
,
139 eFileCondenseCase CaseChange
= kFileNoChange
,
140 BOOL bRequireDrive
= FALSE
);
142 #endif /* __FNAMUTIL_H */