2 * Copyright (c) 2005 Tim Walters. All rights reserved.
3 * Created by Tim Walters on 10/19/05.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
22 #ifndef SC_DIR_UTILS_H_INCLUDED
23 #define SC_DIR_UTILS_H_INCLUDED
31 # define PATH_MAX _MAX_PATH
34 # define snprintf _snprintf
37 #include <boost/algorithm/string.hpp>
39 static inline bool stringCaseCompare(const char * a
, const char * b
)
41 #if _POSIX_VERSION >= 200112L
42 return strcasecmp(a
, b
) == 0;
44 return boost::iequals(a
, b
);
50 # define MAXPATHLEN PATH_MAX
54 #define SC_PATH_DELIMITER "\\"
56 #define SC_PATH_DELIMITER "/"
59 // General path utilities
61 // Add 'component' to 'path' using the platform path separator.
62 void sc_AppendToPath(char *path
, size_t max_size
, const char *component
);
64 // Returns the expanded path with users home directory (also in newpath2)
65 char *sc_StandardizePath(const char *path
, char *newpath2
);
67 // Return TRUE iff 'path' is a symbolic link.
68 bool sc_IsSymlink(const char *path
);
70 // Return TRUE iff 'dirname' is an existing directory.
71 bool sc_DirectoryExists(const char *dirname
);
73 // Returns TRUE iff 'name' is a directory pertaining to another platform.
74 bool sc_IsNonHostPlatformDir(const char *name
);
76 // Returns TRUE iff 'name' is to be ignored during compilation.
77 bool sc_SkipDirectory(const char *name
);
79 int sc_ResolveIfAlias(const char *path
, char *returnPath
, bool &isAlias
, int length
);
81 extern const char * gIdeName
; // string used for conditional compilation according to which IDE is in use this session.
82 // for example, if the value is "scapp" then folders "scide_scapp" will be included, all other "scide_*" excluded.
84 // Support for Bundles
86 void sc_GetResourceDirectory(char* pathBuf
, int length
);
87 bool sc_IsStandAlone();
89 #if defined(__APPLE__) && !defined(SC_IPHONE) // running on OS X
90 void sc_AppendBundleName(char *str
, int size
);
92 // Support for Extensions
94 // Get the user home directory.
95 void sc_GetUserHomeDirectory(char *str
, int size
);
97 // Get the System level data directory.
98 void sc_GetSystemAppSupportDirectory(char *str
, int size
);
100 // Get the User level data directory.
101 void sc_GetUserAppSupportDirectory(char *str
, int size
);
103 // Get the System level 'Extensions' directory.
104 void sc_GetSystemExtensionDirectory(char *str
, int size
);
106 // Get the User level 'Extensions' directory.
107 void sc_GetUserExtensionDirectory(char *str
, int size
);
109 // Get the directory for the configuration files.
110 void sc_GetUserConfigDirectory(char *str
, int size
);
114 // Abstract directory handle
117 // Open directory dirname. Return NULL on failure.
118 SC_DirHandle
* sc_OpenDir(const char *dirname
);
120 // Close directory dir.
121 void sc_CloseDir(SC_DirHandle
*dir
);
123 // Get next entry from directory 'dir' with name 'dirname' and put it into 'path'.
124 // Skip compilation directories iff 'skipEntry' is TRUE.
125 // Return TRUE iff pointing to a valid dir entry.
126 // Return TRUE in 'skipEntry' iff entry should be skipped.
127 bool sc_ReadDir(SC_DirHandle
*dir
, const char *dirname
, char *path
, bool &skipEntry
);
132 // Abstract glob handle
133 struct SC_GlobHandle
;
135 // Create glob iterator from 'pattern'. Return NULL on failure.
136 SC_GlobHandle
* sc_Glob(const char* pattern
);
139 void sc_GlobFree(SC_GlobHandle
* glob
);
141 // Return next path from glob iterator.
142 // Return NULL at end of stream.
143 const char* sc_GlobNext(SC_GlobHandle
* glob
);
145 #endif // SC_DIR_UTILS_H_INCLUDED