Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

unixdirectory.cpp File Reference

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <dirent.h>
#include <wordexp.h>
#include "directory.h"

Include dependency graph for unixdirectory.cpp:

Go to the source code of this file.

Functions

bool IsDirectory (const std::string &filename)
DirectoryOpenDirectory (const std::string &dirname)
std::string WordExp (const std::string &filename)


Function Documentation

bool IsDirectory const std::string filename  ) 
 

Definition at line 93 of file unixdirectory.cpp.

00094 {
00095     struct stat buf;
00096     stat(filename.c_str(), &buf);
00097     return S_ISDIR(buf.st_mode);
00098 }

Directory* OpenDirectory const std::string dirname  ) 
 

Definition at line 87 of file unixdirectory.cpp.

00088 {
00089     return new UnixDirectory(dirname);
00090 }

std::string WordExp const std::string filename  ) 
 

Definition at line 100 of file unixdirectory.cpp.

00100                                              {
00101     wordexp_t result;
00102     std::string expanded;
00103 
00104     switch(wordexp(filename.c_str(), &result, WRDE_NOCMD)) {
00105     case 0: // successful
00106         break;
00107     case WRDE_NOSPACE:
00108             // If the error was `WRDE_NOSPACE',
00109             // then perhaps part of the result was allocated.
00110         wordfree(&result);
00111     default: // some other error
00112         return filename;
00113     }
00114 
00115     if (result.we_wordc != 1) {
00116         wordfree(&result);
00117         return filename;
00118     }
00119 
00120     expanded = result.we_wordv[0];
00121     wordfree(&result);
00122 
00123     return expanded;
00124 }


Generated on Sat Jan 14 22:33:00 2006 for Celestia by  doxygen 1.4.1