Skip to content

Commit

Permalink
move some inline functions to .cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Jul 26, 2013
1 parent 5bc9bff commit 72865ad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
26 changes: 26 additions & 0 deletions src/shogun/io/SGIO.cpp
Expand Up @@ -366,3 +366,29 @@ uint32_t SGIO::ss_length(substring s)
{
return (s.end - s.start);
}

char* SGIO::concat_filename(const char* filename)
{
if (snprintf(file_buffer, FBUFSIZE, "%s/%s", directory_name, filename) > FBUFSIZE)
SG_SERROR("filename too long")

SG_SDEBUG("filename=\"%s\"\n", file_buffer)
return file_buffer;
}

int SGIO::filter(CONST_DIRENT_T* d)
{
if (d)
{
char* fname=concat_filename(d->d_name);

if (!access(fname, R_OK))
{
struct stat s;
if (!stat(fname, &s) && S_ISREG(s.st_mode))
return 1;
}
}

return 0;
}
25 changes: 2 additions & 23 deletions src/shogun/io/SGIO.h
Expand Up @@ -443,35 +443,14 @@ class SGIO
* @param filename new filename
* @return concatenated directory and filename
*/
static inline char* concat_filename(const char* filename)
{
if (snprintf(file_buffer, FBUFSIZE, "%s/%s", directory_name, filename) > FBUFSIZE)
SG_SERROR("filename too long")
SG_SDEBUG("filename=\"%s\"\n", file_buffer)
return file_buffer;
}
static char* concat_filename(const char* filename);

/** filter
*
* @param d directory entry
* @return 1 if d is a readable file
*/
static inline int filter(CONST_DIRENT_T* d)
{
if (d)
{
char* fname=concat_filename(d->d_name);

if (!access(fname, R_OK))
{
struct stat s;
if (!stat(fname, &s) && S_ISREG(s.st_mode))
return 1;
}
}

return 0;
}
static int filter(CONST_DIRENT_T* d);

/**
* Return a C string from the substring
Expand Down

0 comments on commit 72865ad

Please sign in to comment.