File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -177,3 +177,27 @@ mono_path_resolve_symlinks (const char *path)
177
177
#endif
178
178
}
179
179
180
+ /**
181
+ * mono_path_filename_in_basedir:
182
+ *
183
+ * Return \c TRUE if \p filename is in \p basedir
184
+ *
185
+ * Both paths must be absolute and using \c G_DIR_SEPARATOR for directory separators.
186
+ * If the file is in a subdirectory of \p basedir, returns \c FALSE.
187
+ * This function doesn't touch a filesystem, it looks solely at path names.
188
+ */
189
+ gboolean
190
+ mono_path_filename_in_basedir (const char * filename , const char * basedir )
191
+ {
192
+ char * p = NULL ;
193
+ if ((p = strstr (filename , basedir ))) {
194
+ p += strlen (basedir );
195
+ if (* p != G_DIR_SEPARATOR )
196
+ return FALSE;
197
+ /* if it's in a subdir of the basedir, it doesn't count. */
198
+ if (strchr (p , G_DIR_SEPARATOR ))
199
+ return FALSE;
200
+ return TRUE;
201
+ }
202
+ return FALSE;
203
+ }
Original file line number Diff line number Diff line change 10
10
11
11
MONO_API gchar * mono_path_resolve_symlinks (const char * path );
12
12
MONO_API gchar * mono_path_canonicalize (const char * path );
13
+ gboolean mono_path_filename_in_basedir (const char * filename , const char * basedir );
13
14
14
15
#endif /* __MONO_PATH_H */
15
16
You can’t perform that action at this time.
0 commit comments