Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
sfifilecrawler.cc File Reference
#include "sfifilecrawler.hh"
#include "sfiprimitives.hh"
#include "sfiwrapper.hh"
#include <string.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
Include dependency graph for sfifilecrawler.cc:

Macros

#define INCREMENTAL_RESULTS
 

Functions

void _sfi_init_file_crawler (void)
 
SfiFileCrawlersfi_file_crawler_new (void)
 
charsfi_file_crawler_pop (SfiFileCrawler *self)
 
void sfi_file_crawler_set_cwd (SfiFileCrawler *self, const gchar *cwd)
 
void sfi_file_crawler_add_tests (SfiFileCrawler *self, GFileTest tests)
 
void sfi_file_crawler_add_search_path (SfiFileCrawler *self, const gchar *pattern_paths, const gchar *file_pattern)
 
gboolean sfi_file_crawler_needs_crawl (SfiFileCrawler *self)
 
void sfi_file_crawler_crawl (SfiFileCrawler *self)
 
void sfi_file_crawler_destroy (SfiFileCrawler *self)
 
SfiRingsfi_file_crawler_list_files (const gchar *search_path, const gchar *file_pattern, GFileTest file_test)
 
void sfi_make_dirpath (const gchar *dir)
 
void sfi_make_dirname_path (const gchar *file_name)
 
gchar * sfi_path_get_filename (const gchar *filename, const gchar *parentdir)
 
gboolean g_file_test_all (const gchar *file, GFileTest test)
 

Function Documentation

gboolean g_file_test_all ( const gchar *  file,
GFileTest  test 
)
Parameters
filea file to test
testbitfield of GFileTest flags

This is the AND version of g_file_test(). That is, all file tests specified in the test bits have to succed for this function to return TRUE. This function is implemented via Rapicorn::Path::check(), which allowes for more detailed mode tests and is recommended over use of this function. Here is the list of possible GFileTest flags:

  • G_FILE_TEST_IS_REGULAR - test for a recular file
  • G_FILE_TEST_IS_SYMLINK - test for a symlink
  • G_FILE_TEST_IS_DIR - test for a directory
  • G_FILE_TEST_IS_EXECUTABLE - test for an executable
  • G_FILE_TEST_EXISTS - test whether the file exists

Referenced by sfi_file_crawler_add_search_path().

Here is the call graph for this function:

Here is the caller graph for this function:

void sfi_file_crawler_add_search_path ( SfiFileCrawler self,
const gchar *  pattern_paths,
const gchar *  file_pattern 
)
Parameters
selfvalid SfiFileCrawler
pattern_pathscolon (semicolon under win32) seperated search path
file_patternwildcard pattern for file names
Returns
a singly linked list with newly allocated strings

This function takes a search path (possibly containing wildcards) and adds them to the file crawlers search list. If file_pattern is non NULL, it is appended to each directory element extracted from pattern_paths, before attempting file system searches. sfi_file_crawler_needs_crawl() may return TRUE after calling this function.

Referenced by sfi_file_crawler_list_files().

Here is the call graph for this function:

Here is the caller graph for this function:

void sfi_file_crawler_add_tests ( SfiFileCrawler self,
GFileTest  tests 
)
Parameters
selfvalid SfiFileCrawler
testsGFileTest test flags

By default, results returned by self are only tested for existence. If additional file tests have to be met by the results, they can be set by this function.

Referenced by sfi_file_crawler_list_files().

Here is the caller graph for this function:

void sfi_file_crawler_crawl ( SfiFileCrawler self)
Parameters
selfvalid SfiFileCrawler

Collect the next file or directory if possible, new results need not arrive after calling this function, and more than one may. This function does nothing if sfi_file_crawler_needs_crawl() returns FALSE.

Referenced by sfi_file_crawler_list_files().

Here is the caller graph for this function:

void sfi_file_crawler_destroy ( SfiFileCrawler self)
Parameters
selfvalid SfiFileCrawler

Destroy an existing file crawler and free any resources allocated by it.

Referenced by sfi_file_crawler_list_files().

Here is the caller graph for this function:

SfiRing* sfi_file_crawler_list_files ( const gchar *  search_path,
const gchar *  file_pattern,
GFileTest  file_test 
)
Parameters
search_pathcolon (semicolon under win32) seperated search path with '?' and '*' wildcards
file_patternwildcard pattern for file names
cwdassumed current working directoy (to interpret './' in search_path)
file_testGFileTest file test condition (e.g. G_FILE_TEST_IS_REGULAR) or 0
Returns
an SfiRing with newly allocated strings

Given a search path with wildcards, list all files matching file_pattern, contained in the directories which the search path matches. Files that do not pass file_test are not listed.

Here is the call graph for this function:

gboolean sfi_file_crawler_needs_crawl ( SfiFileCrawler self)
Parameters
selfvalid SfiFileCrawler RETURNS: TRUE if sfi_file_crawler_crawl() should be called

Figure whether collecting all matching files has finished now. If not, sfi_file_crawler_crawl() needs to be called until this function returns FALSE.

Referenced by sfi_file_crawler_list_files().

Here is the caller graph for this function:

SfiFileCrawler* sfi_file_crawler_new ( void  )

Create a new file crawler.

A file crawler collects all files matching a given search path and file test. sfi_file_crawler_crawl() needs to be called as long as sfi_file_crawler_needs_crawl() returns TRUE to collect all matching files.

Referenced by sfi_file_crawler_list_files().

Here is the caller graph for this function:

char* sfi_file_crawler_pop ( SfiFileCrawler self)
Parameters
selfvalid SfiFileCrawler RETURNS: newly allocated string containig resulting filename

Fetch next result if any or NULL.

void sfi_file_crawler_set_cwd ( SfiFileCrawler self,
const gchar *  cwd 
)
Parameters
selfvalid SfiFileCrawler
cwdabsolute path

Set the path to be assumed the current working directory.

gchar* sfi_path_get_filename ( const gchar *  filename,
const gchar *  parentdir 
)
Parameters
filenamepossibly relative filename
parentdirpossibly relative parent directory path
Returns
a newly allocated absolute pathname

Construct an absolute filename from filename, using parentdir as parent directory if filename is not absolute. If parentdir is not absolute, it is assumed to be current directory relative. An exception are filenames starting out with '~' and '~USER', these are interpreted to refer to '/home' or '/home/USER' respectively.