00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 #ifndef file_util_INCLUDED 00037 #define file_util_INCLUDED 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 00042 00043 00044 #ifdef _KEEP_RCS_ID 00045 static char *file_util_rcs_id = "$Source: /depot/CVSROOT/javi/src/sw/cmplr/common/util/file_util.h,v $ $Revision: 1.1 $"; 00046 #endif /* _KEEP_RCS_ID */ 00047 00048 /* stdio.h (included in defs.h) defines the following: 00049 * extern FILE *fopen ( char *filename, char *access ); 00050 * extern INT fclose ( FILE *stream ); 00051 * extern void fflush ( FILE *stream ); 00052 * extern void fputs ( char *string, FILE *stream ); 00053 */ 00054 00055 #include <sys/stat.h> /* For fstat() */ 00056 #include <unistd.h> /* For unlink() */ 00057 00058 /* ==================================================================== 00059 * 00060 * Muse File Utility Prototypes 00061 * 00062 * ==================================================================== 00063 */ 00064 00065 /* Determine whether a name is associated with a non-directory file: */ 00066 extern BOOL Is_File ( const char *fname ); 00067 00068 /* Determine whether two streams are associated with the same file: */ 00069 extern BOOL Same_File (FILE *file1, FILE *file2); 00070 00071 /* Determine whether a filename has a given extension: */ 00072 extern BOOL Has_Extension ( 00073 char *name, /* The filename to check */ 00074 char *ext /* The extension to look for */ 00075 ); 00076 00077 /* Search for a file with a specific extension. First look for the 00078 * name given; if not found, and the name does not already have the 00079 * given extension, look for the name with the extension appended. 00080 * The name string passed must have enough space to append the 00081 * extension, and if that is the form found, it will be appended on 00082 * return. 00083 */ 00084 extern BOOL Find_File ( 00085 char *name, /* The initial filename to search for */ 00086 char *ext /* The default extension to try */ 00087 ); 00088 00089 /* Replace the given file name's extension with another extension and 00090 * return a new filename string. The given extension should include 00091 * the period if desired (a period in the original name will be 00092 * eliminated). 00093 */ 00094 extern char *New_Extension ( 00095 const char *name, /* The root file name, possibly with extension */ 00096 const char *ext /* The new extension */ 00097 ); 00098 00099 extern char *Remove_Extension ( 00100 char *name /* The original file name */ 00101 ); 00102 00103 /* Make a temporary file name from a temporary directory name, a file 00104 * name prefix, and the process ID: 00105 */ 00106 extern char *Make_Temp_File ( 00107 char *tmp, /* Temporary directory pathname to use */ 00108 char *prefix /* Prefix for file name */ 00109 ); 00110 00111 /* Make a full path name from a base file name: */ 00112 extern char *Full_Path_Name ( 00113 char *base, /* Base file name (may be full pathname) */ 00114 char *path, /* String to receive pathname */ 00115 INT pathlen /* Length of path -- exceeding is a fatal error */ 00116 ); 00117 00118 /* Return the last component of the pathname specified in 'pname'. 00119 * Note that we return a pointer to a portion of the input string. 00120 * Therefore, if the caller wants to modify the returned value, the 00121 * caller must first make a copy. 00122 */ 00123 extern char *Last_Pathname_Component ( char *pname ); 00124 00125 /* Make an absolute path name from the file name, 00126 * which means no .. or . or // in the path. */ 00127 extern char *Make_Absolute_Path (char *filename); 00128 00129 /* return getcwd or $PWD or . */ 00130 extern char * Get_Current_Working_Directory (void); 00131 00132 #ifdef __cplusplus 00133 } 00134 #endif 00135 #endif /* file_util_INCLUDED */
1.5.6