aboutsummaryrefslogtreecommitdiffhomepage
path: root/wildcard.c
diff options
context:
space:
mode:
authorGravatar liljencrantz <liljencrantz@gmail.com>2008-01-14 02:47:47 +1000
committerGravatar liljencrantz <liljencrantz@gmail.com>2008-01-14 02:47:47 +1000
commit87db9517e928c9007c66ed5b23836db2dad2b693 (patch)
treeedfe373687a5afb9ba5360a456e3096d7bf2df85 /wildcard.c
parentab3502fc8b25469429af25a94306346af590428c (diff)
Add lots of new code comments.
darcs-hash:20080113164747-75c98-9d0cefd27be7aef7ba60772616d9da7e6bb52912.gz
Diffstat (limited to 'wildcard.c')
-rw-r--r--wildcard.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/wildcard.c b/wildcard.c
index 9456b85f..f585dbb9 100644
--- a/wildcard.c
+++ b/wildcard.c
@@ -378,7 +378,11 @@ static wchar_t *make_path( const wchar_t *base_dir, const wchar_t *name )
return long_name;
}
-
+/**
+ Return a description of a file based on its suffix. This function
+ does not perform any caching, it directly calls the mimedb command
+ to do a lookup.
+ */
static wchar_t *complete_get_desc_suffix_internal( const wchar_t *suff_orig )
{
@@ -425,15 +429,22 @@ static wchar_t *complete_get_desc_suffix_internal( const wchar_t *suff_orig )
return desc;
}
+/**
+ Free the suffix_hash hash table and all memory used by it.
+ */
static void complete_get_desc_destroy_suffix_hash()
{
- hash_foreach( suffix_hash, &clear_hash_entry );
- hash_destroy( suffix_hash );
- free( suffix_hash );
+ if( suffix_hash )
+ {
+ hash_foreach( suffix_hash, &clear_hash_entry );
+ hash_destroy( suffix_hash );
+ free( suffix_hash );
+ }
}
+
/**
Use the mimedb command to look up a description for a given suffix
*/
@@ -759,7 +770,14 @@ static int test_flags( wchar_t *filename,
return 1;
}
+/**
+ The real implementation of wildcard expansion is in this
+ function. Other functions are just wrappers around this one.
+ This function traverses the relevant directory tree looking for
+ matches, and recurses when needed to handle wildcrards spanning
+ multiple components and recursive wildcards.
+ */
static int wildcard_expand_internal( const wchar_t *wc,
const wchar_t *base_dir,
int flags,