(file) Return to FileSystem.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/FileSystem.cpp between version 1.1 and 1.2

version 1.1, 2001/01/14 19:51:35 version 1.2, 2001/02/11 05:42:33
Line 23 
Line 23 
 // Author: // Author:
 // //
 // $Log$ // $Log$
 // Revision 1.1  2001/01/14 19:51:35  mike  // Revision 1.2  2001/02/11 05:42:33  mike
 // Initial revision  // new
   //
   // Revision 1.1.1.1  2001/01/14 19:51:35  mike
   // Pegasus import
 // //
 // //
 //END_HISTORY //END_HISTORY
Line 44 
Line 47 
 #include <cstdio> #include <cstdio>
 #include "Destroyer.h" #include "Destroyer.h"
 #include "FileSystem.h" #include "FileSystem.h"
   #include "Dir.h"
  
 // ATTN-B: porting! // ATTN-B: porting!
  
Line 84 
Line 88 
 #endif #endif
 } }
  
   Boolean FileSystem::existsIgnoreCase(const String& path, String& realPath)
   {
       realPath.clear();
       Destroyer<char> destroyer(_clonePath(path));
       char* p = destroyer.getPointer();
   
       char* dirPath;
       char* fileName;
       char* slash = strrchr(p, '/');
   
       if (slash)
       {
           *slash = '\0';
           fileName = slash + 1;
           dirPath = p;
           if (*fileName == '\0')
               return false;
       }
       else
       {
           fileName = p;
           dirPath = ".";
       }
   
       for (Dir dir(dirPath); dir.more(); dir.next())
       {
   #ifdef PEGASUS_OS_TYPE_WINDOWS
           if (stricmp(fileName, dir.getName()) == 0)
   #else
           if (strcasecmp(fileName, dir.getName()) == 0)
   #endif
           {
               if (strcmp(dirPath, ".") == 0)
                   realPath = dir.getName();
               else
               {
                   realPath = dirPath;
                   realPath += '/';
                   realPath += dir.getName();
               }
               return true;
           }
       }
   
       return false;
   }
   
 Boolean FileSystem::canRead(const String& path) Boolean FileSystem::canRead(const String& path)
 { {
     Destroyer<char> p(_clonePath(path));     Destroyer<char> p(_clonePath(path));
Line 265 
Line 316 
 { {
     paths.clear();     paths.clear();
  
 #ifdef PEGASUS_OS_TYPE_WINDOWS      for (Dir dir(path); dir.more(); dir.next())
   
     String tmp = path;  
     tmp += "/*";  
     Destroyer<char> p(tmp.allocateCString());  
   
     long file;  
     struct _finddata_t findData;  
   
     if ((file = _findfirst(p.getPointer(), &findData)) == -1L)  
         return false;  
   
     do  
     {     {
         const char* name = findData.name;          String name = dir.getName();
  
         if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)          if (name == "." || name ==  "..")
             continue;  
   
         paths.append(name);  
   
     } while (_findnext(file, &findData) == 0);  
   
     _findclose(file);  
   
 #else  
   
     Destroyer<char> p(_clonePath(path));  
     DIR* dir = opendir(p.getPointer());  
   
     if (!dir)  
         return false;  
   
     struct dirent* entry;  
   
     while ((entry = readdir(dir)) != NULL)  
     {  
         const char* name = entry->d_name;  
   
         if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)  
             continue;             continue;
  
         paths.append(name);         paths.append(name);
     }     }
  
     closedir(dir);  
 #endif  
   
     return true;     return true;
 } }
  


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2