Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FileSystem
[Base]


Namespaces

namespace  osg::AccessFlags
namespace  osg::File
namespace  osg::Directory

Directory Functions

Char8osg::Directory::getCurrent (void)
std::vector< Char8 * > * osg::Directory::getEntries (const Char8 *szDirname, const Char8 *szPattern)
bool osg::Directory::setCurrent (const Char8 *szDirname)

AccessFlags

*const UInt32 osg::AccessFlags::None = 0x00
const UInt32 osg::AccessFlags::IsReadable = 0x01
const UInt32 osg::AccessFlags::IsWriteable = 0x02

Detailed Description

ToDo

Function Documentation

Char8* osg::Directory::getCurrent void   )  [inline]
 

Definition at line 200 of file OSGFileSystem.inl.

Referenced by osg::ExternalThread::getCurrent(), osg::Thread::getCurrent(), osg::BaseThread::getCurrent(), osg::PathHandler::push_backCurrentDir(), osg::PathHandler::push_frontCurrentDir(), osg::QSceneGraphView::QSceneGraphView(), and osg::Image::read().

00201     {
00202         UInt32 uiCurrentNameSize = 256;
00203         
00204         Char8 *returnValue = new Char8[uiCurrentNameSize];
00205         Char8 *szTmpBuf;
00206         
00207         while(1)
00208         {
00209 #ifndef WIN32
00210             szTmpBuf =  getcwd(returnValue, uiCurrentNameSize);
00211 #else
00212             szTmpBuf = _getcwd(returnValue, uiCurrentNameSize);
00213 #endif
00214             if(szTmpBuf != NULL)
00215                 break;
00216             
00217             uiCurrentNameSize *= 2;
00218             delete [] returnValue;
00219             
00220             returnValue = new Char8[uiCurrentNameSize];
00221         }
00222         
00223         return returnValue;
00224     }

std::vector<Char8 *>* osg::Directory::getEntries const Char8 szDirname,
const Char8 szPattern
[inline]
 

Definition at line 253 of file OSGFileSystem.inl.

References osg::AccessFlags::IsReadable, osg::stringDup(), osg::stringlen(), and osg::File::tstAttr().

Referenced by osg::osgInit().

00255     {
00256         std::vector<Char8 *> *returnValue = NULL;
00257         
00258         if(szDirname != NULL)
00259         {
00260             if(tstAttr(szDirname, AccessFlags::IsReadable) == true)
00261             {
00262 #ifndef WIN32
00263                 DIR    *pDir        = opendir(szDirname);
00264                 dirent *pDirEntry   = NULL;
00265                 Char8  *szEntryName = NULL;
00266                 
00267                 if(pDir != NULL)
00268                 {
00269                     returnValue = new std::vector<Char8 *>;
00270 
00271                     do
00272                     {
00273                         pDirEntry = readdir(pDir);
00274                         
00275                         if(pDirEntry != NULL)
00276                         {
00277                             stringDup(pDirEntry->d_name, szEntryName);
00278                             
00279                             if(szPattern != NULL)
00280                             {
00281                                 if(fnmatch(szPattern, szEntryName, 0) == 0)
00282                                 {
00283                                     returnValue->push_back(szEntryName);
00284                                 }
00285                                 else
00286                                 {
00287                                     delete [] szEntryName;
00288                                 }
00289                             }
00290                             else
00291                             {
00292                                 returnValue->push_back(szEntryName);
00293                             }
00294 
00295                             szEntryName = NULL;
00296                         }
00297                     }
00298                     while(pDirEntry != NULL);
00299                     
00300                     closedir(pDir);
00301                 }
00302 #else
00303                 Char8           *szTmpDirname = NULL;
00304                 
00305                 bool             bVal;
00306                 WIN32_FIND_DATA  pDirEntry;
00307                 HANDLE           pDir;
00308                 Char8           *szEntryName = NULL;
00309                 
00310                 if(szPattern == NULL)
00311                 {
00312                     szTmpDirname = new Char8[stringlen(szDirname) + 5];
00313                     
00314                     sprintf(szTmpDirname, "%s\\*", szDirname);
00315                 }
00316                 else
00317                 {
00318                     szTmpDirname = new Char8[stringlen(szDirname) +
00319                                              stringlen(szPattern) + 
00320                                              5];
00321                     
00322                     sprintf(szTmpDirname, "%s\\%s", szDirname, szPattern);
00323                 }
00324                 
00325                 pDir = FindFirstFile(szTmpDirname, &pDirEntry);
00326                 
00327 #ifdef OSG_WIN32_ICL
00328 #pragma warning (disable : 171)
00329 #endif
00330                 
00331                 if(INVALID_HANDLE_VALUE != pDir)
00332                 {
00333                     returnValue = new std::vector<Char8 *>;
00334                     
00335                     do
00336                     {
00337                         stringDup(pDirEntry.cFileName, szEntryName);
00338                         
00339                         returnValue->push_back(szEntryName);
00340                         szEntryName = NULL;
00341                         
00342                         bVal = (FindNextFile(pDir, &pDirEntry) != FALSE);
00343                     }
00344                     while(bVal == true);
00345                     
00346                     FindClose(pDir);
00347                 }
00348                 
00349 #ifdef OSG_WIN32_ICL
00350 #pragma warning (error : 171)
00351 #endif
00352                 
00353                 delete szTmpDirname;
00354 #endif
00355             }
00356         }
00357         
00358         return returnValue;
00359     }

bool osg::Directory::setCurrent const Char8 szDirname  )  [inline]
 

Definition at line 231 of file OSGFileSystem.inl.

00232     {
00233         bool returnValue = false;
00234         
00235         if(szDirname != NULL)
00236         {
00237 #ifndef WIN32
00238             if(chdir(szDirname) == 0)
00239                 returnValue = true;
00240 #else
00241             if(_chdir(szDirname) == 0)
00242                 returnValue = true;
00243 #endif
00244         }
00245         
00246         return returnValue;
00247     }


Variable Documentation

* const UInt32 osg::AccessFlags::None = 0x00
 

Definition at line 79 of file OSGFileSystem.h.

Referenced by osg::XWindow::deactivate(), osg::XWindow::init(), and osg::QTWindow::init().

const UInt32 osg::AccessFlags::IsReadable = 0x01
 

Definition at line 80 of file OSGFileSystem.h.

Referenced by osg::PathHandler::findFile(), osg::Directory::getEntries(), osg::Directory::tstAttr(), and osg::File::tstAttr().

const UInt32 osg::AccessFlags::IsWriteable = 0x02
 

Definition at line 81 of file OSGFileSystem.h.

Referenced by osg::Directory::tstAttr(), and osg::File::tstAttr().


Generated on Thu Aug 25 04:12:27 2005 for OpenSG by  doxygen 1.4.3