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

Diff for /pegasus/src/Pegasus/Common/FileSystem.h between version 1.10 and 1.28

version 1.10, 2001/05/14 00:39:53 version 1.28, 2003/08/12 19:37:55
Line 1 
Line 1 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
   // The Open Group, Tivoli Systems
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a  // Permission is hereby granted, free of charge, to any person obtaining a copy
 // copy of this software and associated documentation files (the "Software"),  // of this software and associated documentation files (the "Software"), to
 // to deal in the Software without restriction, including without limitation  // deal in the Software without restriction, including without limitation the
 // the rights to use, copy, modify, merge, publish, distribute, sublicense,  // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 // and/or sell copies of the Software, and to permit persons to whom the  // sell copies of the Software, and to permit persons to whom the Software is
 // Software is furnished to do so, subject to the following conditions:  // furnished to do so, subject to the following conditions:
 // //
 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,  // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL  // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING  // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 // DEALINGS IN THE SOFTWARE.  // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
   // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 // //
 //============================================================================== //==============================================================================
 // //
Line 28 
Line 30 
 #ifndef Pegasus_FileSystem_h #ifndef Pegasus_FileSystem_h
 #define Pegasus_FileSystem_h #define Pegasus_FileSystem_h
  
 #include <fstream>  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #include <Pegasus/Common/String.h> #include <Pegasus/Common/String.h>
 #include <Pegasus/Common/Array.h>  #include <Pegasus/Common/ArrayInternal.h>
 #include <Pegasus/Common/Exception.h>  #include <Pegasus/Common/InternalException.h>
   #include <Pegasus/Common/System.h>
   #include <Pegasus/Common/Linkage.h>
   #include <fstream>
   #include <cstdio>
   #if defined(PEGASUS_OS_OS400)
   #include "OS400ConvertChar.h"
   #endif
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 174 
Line 182 
         const String& oldPath,         const String& oldPath,
         const String& newPath);         const String& newPath);
  
       /** Same as rename file except that the case of the file referred to
           by oldPath is ignored.
       */
       static Boolean renameFileNoCase(
           const String& oldPath,
           const String& newPath);
   
       /** Copy a file.
           @param fromPath name of existing file.
           @param toPath name of new file.
           @return true on success.
       */
       static Boolean copyFile(
           const String& fromPath,
           const String& toPath);
   
     /** Opens a file and ignores the case of the file. Note that the file     /** Opens a file and ignores the case of the file. Note that the file
         will be opend in binary mode (no translation of carriage-return-line-         will be opend in binary mode (no translation of carriage-return-line-
         feed sequences on Windows).         feed sequences on Windows).
Line 181 
Line 205 
         @param path path of file to be opened.         @param path path of file to be opened.
         @return true on success.         @return true on success.
     */     */
     Boolean openNoCase(std::ifstream& is, const String& path);      static Boolean openNoCase(PEGASUS_STD(ifstream)& is, const String& path);
   
       /** Opens a file and ignores the case of the file. Note that the file
           open mode of the file must be passed in.
           @param os file stream to be opend.
           @param path path of file to be opened.
           @param mode mode to open the file in.
           @return true on success.
       */
       static Boolean openNoCase(
           PEGASUS_STD(fstream)& fs,
           const String& path,
           int mode);
  
     /** Determines whether the path refers to a directory.     /** Determines whether the path refers to a directory.
         @param path path of the directory.         @param path path of the directory.
Line 250 
Line 286 
     */     */
     static void translateSlashes(String& path);     static void translateSlashes(String& path);
  
       /** Get an absolute path from an absolute directory and a relative or
           absolute file name.  If the file name is fully specified, it is
           returned unchanged.  Otherwise, the specified directory is prepended
           to the file name.
       */
       static String getAbsolutePath(const char* path, const String& filename);
   
       /** Return the just the filename to the file name into base.
       */
       static String extractFileName(const String& base);
   
       /** Return the just the path to the file name into path.
       */
       static String extractFilePath(const String& path);
   
 private: private:
  
     FileSystem() { }     FileSystem() { }
Line 291 
Line 342 
     return FileSystem::removeFile(realPath);     return FileSystem::removeFile(realPath);
 } }
  
   inline Boolean FileSystem::renameFileNoCase(
       const String& oldPath,
       const String& newPath)
   {
       String realPath;
   
       if (!existsNoCase(oldPath, realPath))
           return false;
   
       return FileSystem::renameFile(realPath, newPath);
   }
   
 inline Boolean FileSystem::getFileSizeNoCase(const String& path, Uint32& size) inline Boolean FileSystem::getFileSizeNoCase(const String& path, Uint32& size)
 { {
     String realPath;     String realPath;
Line 301 
Line 364 
     return FileSystem::getFileSize(realPath, size);     return FileSystem::getFileSize(realPath, size);
 } }
  
   inline String FileSystem::getAbsolutePath(
       const char* path,
       const String& filename)
   {
       String absolutePath;
   
       if (filename != String::EMPTY)
       {
           if (!System::is_absolute_path(filename.getCString()) && path && path[0])
           {
               absolutePath.append(path);
               absolutePath.append('/');
           }
           absolutePath.append(filename);
       }
       translateSlashes(absolutePath);
   
       return absolutePath;
   }
   
   inline Boolean Open(PEGASUS_STD(ifstream)& is, const String& path)
   {
   #if defined(PEGASUS_OS_OS400)
       CString tempPath = path.getCString();
       const char * tmp = tempPath;
       AtoE((char *)tmp);
       is.open(tmp, PEGASUS_STD(_CCSID_T(1208)));
   #else
       is.open(path.getCString());
   #endif
       return !!is;
   }
   
   inline Boolean Open(PEGASUS_STD(ofstream)& os, const String& path)
   {
   #if defined(PEGASUS_OS_OS400)
       CString tempPath = path.getCString();
       const char * tmp = tempPath;
       AtoE((char *)tmp);
       os.open(tmp, PEGASUS_STD(_CCSID_T(1208)));
   #else
       os.open(path.getCString());
   #endif
       return !!os;
   }
   
   inline Boolean OpenAppend(PEGASUS_STD(ofstream)& os, const String& path)
   {
   #if defined(PEGASUS_OS_OS400)
       CString tempPath = path.getCString();
       const char * tmp = tempPath;
       AtoE((char *)tmp);
       os.open(tmp, PEGASUS_STD(ios::app), PEGASUS_STD(_CCSID_T(1208)));
   #else
       os.open(path.getCString(), PEGASUS_STD(ios::app));
   #endif
       return !!os;
   }
   
   /** Get the next line from the input file.
   */
   PEGASUS_COMMON_LINKAGE Boolean GetLine(PEGASUS_STD(istream)& is, String& line);
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END
  
 #endif /* Pegasus_FileSystem_h */ #endif /* Pegasus_FileSystem_h */


Legend:
Removed from v.1.10  
changed lines
  Added in v.1.28

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2