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

  1 mike  1.6 //%/////////////////////////////////////////////////////////////////////////////
  2 mike  1.1 //
  3           // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
  4           //
  5           // Permission is hereby granted, free of charge, to any person obtaining a
  6           // copy of this software and associated documentation files (the "Software"),
  7           // to deal in the Software without restriction, including without limitation
  8           // the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9           // and/or sell copies of the Software, and to permit persons to whom the
 10           // Software is furnished to do so, subject to the following conditions:
 11           //
 12           // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 13           // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 14           // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 15           // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 16           // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 17           // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 18           // DEALINGS IN THE SOFTWARE.
 19           //
 20 mike  1.6 //==============================================================================
 21 mike  1.1 //
 22 mike  1.6 // Author: Mike Brasher (mbrasher@bmc.com)
 23 mike  1.1 //
 24 mike  1.6 // Modified By:
 25 mike  1.5 //
 26 mike  1.6 //%/////////////////////////////////////////////////////////////////////////////
 27 mike  1.1 
 28           ////////////////////////////////////////////////////////////////////////////////
 29           //
 30           // FileSystem.h
 31           //
 32           //	This class provides utilities for manipulating and interrogating the
 33           //	file system.
 34           //
 35           ////////////////////////////////////////////////////////////////////////////////
 36           
 37           #ifndef Pegasus_FileSystem_h
 38           #define Pegasus_FileSystem_h
 39           
 40           #include <Pegasus/Common/Config.h>
 41           #include <Pegasus/Common/String.h>
 42 karl  1.4 #include <Pegasus/Common/Array.h>
 43 mike  1.1 #include <Pegasus/Common/Exception.h>
 44           
 45           PEGASUS_NAMESPACE_BEGIN
 46           
 47           class PEGASUS_COMMON_LINKAGE FileSystem
 48           {
 49           public:
 50           
 51 mike  1.2     /// Return true if the file exists (and false otherwise).
 52               static Boolean exists(const String& path);
 53 mike  1.1 
 54 mike  1.2     /** Return true if the file exists (and false otherwise). Ignore the
 55           	case of the file and return the real name of the file.
 56               */
 57               static Boolean existsIgnoreCase(const String& path, String& realPath);
 58 mike  1.1 
 59               // Returns true if the file exists and can be read:
 60           
 61               static Boolean canRead(const String& path);
 62           
 63               // Returns true if the file exists and can be written:
 64           
 65               static Boolean canWrite(const String& path);
 66           
 67               // Returns true if the file exists and can be executed:
 68           
 69               // static Boolean canExecute(const String& path);
 70           
 71               // Returns true if file exists and is a directory:
 72           
 73               static Boolean isDirectory(const String& path);
 74           
 75               // Change to the given directory:
 76           
 77               static Boolean changeDirectory(const String& path);
 78           
 79 mike  1.1     // Create a directory:
 80           
 81               static Boolean makeDirectory(const String& path);
 82           
 83               // Get the size of the file in bytes:
 84           
 85               static Boolean getFileSize(const String& path, Uint32& size);
 86 mike  1.8 
 87               /** Get the current working Directory. */
 88 karl  1.4     static Boolean getCurrentDirectory(String& path);
 89 mike  1.1 
 90 karl  1.4     /** Remove the given directory. The directory must be empty
 91           	to be eligible for removal
 92           	@param String path is the relative or ablsolute path to
 93           	the directory to remove
 94           	@return true if directory removed
 95               */
 96 mike  1.1     static Boolean removeDirectory(const String& path);
 97           
 98 karl  1.4     /** Remove a directory hiearchy. Removes a complete hiearchy of
 99           	directories and files.
100           	
101           	WARNING: This differs significantly from the <TT>removeDirectory</TT>
102           	function in that it removes both directories and files and
103           	removes a complete hiearchy.  Use with caution.
104           	
105           	@parm path defines the high level directory to be removed
106           	@return Boolean - ATTN.
107           	@exception  - ATTN: Not sure if there is any exception
108               */ 
109               static Boolean removeDirectoryHier(const String& path);
110           
111               /** Remove the file defined by the input parameter
112           	@param path of file to remove
113           	@return Boolean true if directory removed
114               */
115 mike  1.1     static Boolean removeFile(const String& path);
116           
117 karl  1.4     /** Get the names of the files (and directories) in the given directory:
118 mike  1.1 
119 karl  1.4 	@param path - the path of the directory from which we will get filenames
120           	@param paths - On return, this  Array contains the names of the files 
121           	in the directory
122           	ATTN: Is this local names or fully qualified names with paths.
123           	@return Boolean that is today only true.
124           	@exception Throws "NoSuchDirectory" if the directory defined in path does 
125           	not exist.
126               */
127 mike  1.1     static Boolean getDirectoryContents(
128           	const String& path,
129           	Array<String>& paths);
130           
131 karl  1.4     /** Load the contents of the file into the array. Throws CannotOpenFile if
132           	unable to open file.
133               */
134 mike  1.1 
135               static void loadFileToMemory(
136           	Array<Sint8>& array,
137           	const String& fileName);
138           
139 karl  1.4     /** Compare two file for content.
140 mike  1.7 	@param filename of first file
141           	@param filename of second file
142           	ATTN: are filenames local or global???
143           	@return Return true if the two files are identical. 
144           	@exception Throws CannotOpenFile if either file cannot be opened.
145 karl  1.4     */
146 mike  1.1     static Boolean compare(
147           	const String& fileName1,
148           	const String& fileName2);
149 mike  1.3 
150 mike  1.7     /** Rename the given file to the new name. */
151 mike  1.3     static Boolean renameFile(
152           	const String& oldFileName,
153           	const String& newFileName);
154 mike  1.5 
155 mike  1.7     /** Translate backward slashes to forward slashes: */
156               static void translateSlashes(String& path);
157 mike  1.5 
158 mike  1.7     /** Returns true is the given directory is empty. */
159               static Boolean isDirectoryEmpty(const String& path);
160 mike  1.1 };
161           
162           PEGASUS_NAMESPACE_END
163           
164           #endif /* Pegasus_FileSystem_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2