(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.40 and 1.57

version 1.40, 2002/09/11 19:11:54 version 1.57, 2005/06/03 19:47:32
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2005////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 25 
Line 31 
 // //
 // Modified By: // Modified By:
 //         Ramnath Ravindran(Ramnath.Ravindran@compaq.com) //         Ramnath Ravindran(Ramnath.Ravindran@compaq.com)
   //         Amit K Arora, IBM (amita@in.ibm.com)
   //         Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
   //         Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
   //         David Dillard, VERITAS Software Corp.
   //             (david.dillard@veritas.com)
   //         Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <iostream> #include <iostream>
 #include <cstdio>  //#include <cstdio>
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
 #include "Destroyer.h"  #include <Pegasus/Common/AutoPtr.h>
 #include "FileSystem.h" #include "FileSystem.h"
 #include "Dir.h" #include "Dir.h"
  
Line 69 
Line 81 
  
 Boolean FileSystem::existsNoCase(const String& path, String& realPath) Boolean FileSystem::existsNoCase(const String& path, String& realPath)
 { {
   #ifdef PEGASUS_OS_OS400
       // The OS/400 file system is case insensitive, so just call exists( ).
       // This is faster, but the main reason to do this is to
       // avoid multi-threading problems with the IFS directory APIs
       // (even though they claim to be threadsafe).
       realPath = path;
       return exists(path);
   #else
     realPath.clear();     realPath.clear();
     CString cpath = _clonePath(path);     CString cpath = _clonePath(path);
     const char* p = cpath;     const char* p = cpath;
Line 110 
Line 130 
     }     }
  
     return false;     return false;
   #endif
 } }
  
 Boolean FileSystem::canRead(const String& path) Boolean FileSystem::canRead(const String& path)
Line 133 
Line 154 
 } }
  
 void FileSystem::loadFileToMemory( void FileSystem::loadFileToMemory(
     Array<Sint8>& array,      Array<char>& array,
     const String& fileName)     const String& fileName)
 { {
     Uint32 fileSize;     Uint32 fileSize;
Line 151 
Line 172 
     size_t n;     size_t n;
  
     while ((n = fread(buffer, 1, sizeof(buffer), fp)) > 0)     while ((n = fread(buffer, 1, sizeof(buffer), fp)) > 0)
         array.append(buffer, n);          array.append(buffer, static_cast<Uint32>(n));
  
     fclose(fp);     fclose(fp);
 } }
Line 226 
Line 247 
         return false;         return false;
  
     is.open(_clonePath(realPath) PEGASUS_IOS_BINARY);     is.open(_clonePath(realPath) PEGASUS_IOS_BINARY);
   
     return !!is;     return !!is;
 } }
  
Line 238 
Line 260 
  
     if (!existsNoCase(path, realPath))     if (!existsNoCase(path, realPath))
         return false;         return false;
   #if defined(__GNUC__) && GCC_VERSION >= 30200
       fs.open(_clonePath(realPath), PEGASUS_STD(ios_base::openmode)(mode));
   #else
   #if defined(PEGASUS_OS_OS400)
       fs.open(_clonePath(realPath), mode, PEGASUS_STD(_CCSID_T(1208)) );
   #else
     fs.open(_clonePath(realPath), mode);     fs.open(_clonePath(realPath), mode);
   #endif
   #endif
     return !!fs;     return !!fs;
 } }
  
Line 357 
Line 386 
     }     }
 } }
  
   // Return the just the base name from the path.
   String  FileSystem::extractFileName(const String& path)
   {
     AutoArrayPtr<char> p_path(new char[path.size() + 1]);
     String basename = System::extract_file_name((const char *)path.getCString(), p_path.get());
   
     return basename;
   }
   
   // Return just the path to the file or directory into path
   String FileSystem::extractFilePath(const String& path)
   {
     AutoArrayPtr<char> p_path(new char[path.size() + 1]);
     String newpath = System::extract_file_path((const char *)path.getCString(), p_path.get());
   
     return newpath;
   }
   
   // Changes file permissions on the given file.
   Boolean FileSystem::changeFilePermissions(const String& path, mode_t mode)
   {
   #if defined(PEGASUS_OS_OS400)
       // ATTN: If getCString() is modified to return UTF8, then handle the
       //       EBCDIC coversion in SystemUnix.cpp
       CString tempPath = path.getCString();
   #else
       CString tempPath = path.getCString();
   #endif
   
       return System::changeFilePermissions(tempPath, mode);
   }
   
   String FileSystem::getAbsoluteFileName(const String &paths, const String &filename) {
   
     Uint32 pos =0;
     Uint32 token=0;
     String path = String::EMPTY;
     String root = String::EMPTY;
     String tempPath = paths;
   
   #if defined(PEGASUS_OS_VMS)
   
     if (FileSystem::exists(paths + filename) == true)
     {
       root = filename;
     }
   #else
     do {
       if (( pos = tempPath.find(FileSystem::getPathDelimiter())) == PEG_NOT_FOUND) {
                   pos = tempPath.size();
                   token = 0;
           }
           else {
                   token = 1;
           }
           path = tempPath.subString(0, pos);
           tempPath.remove(0,pos+token);
           if (FileSystem::exists( path + "/" + filename) == true) {
             root = path + "/" + filename;
             break;
           } else
             {
             //  cout << "File does not exist.\n";
             }
     } while (tempPath.size() > 0);
   #endif
     return root;
   }
   
   String FileSystem::buildLibraryFileName(const String &libraryName)
   {
       String fileName;
   
       //
       // Add the necessary prefix and suffix to convert the library name to its
       // corresponding file name.
       //
   #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
       fileName = libraryName + String(".dll");
   #elif defined(PEGASUS_PLATFORM_HPUX_PARISC_ACC)
       fileName = String("lib") + libraryName + String(".sl");
   #elif defined(PEGASUS_OS_OS400)
       fileName = libraryName;
   #elif defined(PEGASUS_OS_DARWIN)
       fileName = String("lib") + libraryName + String(".dylib");
   #elif defined(PEGASUS_OS_VMS)
       fileName = String("lib") + libraryName;
   #else
       fileName = String("lib") + libraryName + String(".so");
   #endif
   
       return fileName;
   }
   
   
 Boolean GetLine(PEGASUS_STD(istream)& is, String& line) Boolean GetLine(PEGASUS_STD(istream)& is, String& line)
 { {
     line.clear();     line.clear();


Legend:
Removed from v.1.40  
changed lines
  Added in v.1.57

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2