Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
file_util.h
Go to the documentation of this file.
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 #endif /* _KEEP_RCS_ID */
00046 
00047 /* stdio.h (included in defs.h) defines the following:
00048  *      extern FILE *fopen ( char *filename, char *access );
00049  *      extern INT  fclose ( FILE *stream );
00050  *      extern void fflush ( FILE *stream );
00051  *      extern void fputs  ( char *string, FILE *stream );
00052  */
00053 
00054 #include <sys/stat.h>           /* For fstat() */
00055 #include <unistd.h>               /* For unlink() */
00056 
00057 /* ====================================================================
00058  *
00059  * Muse File Utility Prototypes
00060  *
00061  * ====================================================================
00062  */
00063 
00064 /* Determine whether a name is associated with a non-directory file: */
00065 extern BOOL Is_File ( const char *fname );
00066 
00067 /* Determine whether two streams are associated with the same file: */
00068 extern BOOL Same_File (FILE *file1, FILE *file2);
00069 
00070 /* Determine whether a filename has a given extension: */
00071 extern BOOL Has_Extension (
00072   char *name,   /* The filename to check */
00073   char *ext     /* The extension to look for */
00074 );
00075 
00076 /* Search for a file with a specific extension.  First look for the
00077  * name given; if not found, and the name does not already have the
00078  * given extension, look for the name with the extension appended.
00079  * The name string passed must have enough space to append the
00080  * extension, and if that is the form found, it will be appended on
00081  * return.
00082  */
00083 extern BOOL Find_File (
00084   char *name,   /* The initial filename to search for */
00085   char *ext     /* The default extension to try */
00086 );
00087 
00088 /* Replace the given file name's extension with another extension and
00089  * return a new filename string.  The given extension should include
00090  * the period if desired (a period in the original name will be
00091  * eliminated).
00092  */
00093 extern char *New_Extension (
00094   const char *name,     /* The root file name, possibly with extension */
00095   const char *ext       /* The new extension */
00096 );
00097 
00098 extern char *Remove_Extension (
00099   char *name    /* The original file name */
00100 );
00101 
00102 /* Make a temporary file name from a temporary directory name, a file
00103  * name prefix, and the process ID:
00104  */
00105 extern char *Make_Temp_File (
00106   char *tmp,    /* Temporary directory pathname to use */
00107   char *prefix  /* Prefix for file name */
00108 );
00109 
00110 /* Make a full path name from a base file name: */
00111 extern char *Full_Path_Name (
00112   char *base,   /* Base file name (may be full pathname) */
00113   char *path,   /* String to receive pathname */
00114   INT pathlen   /* Length of path -- exceeding is a fatal error */
00115 );
00116 
00117 /* Return the last component of the pathname specified in 'pname'.
00118  * Note that we return a pointer to a portion of the input string.
00119  * Therefore, if the caller wants to modify the returned value, the
00120  * caller must first make a copy.
00121  */
00122 extern char *Last_Pathname_Component ( char *pname );
00123 
00124 /* Make an absolute path name from the file name,
00125  * which means no .. or . or // in the path. */
00126 extern char *Make_Absolute_Path (char *filename);
00127 
00128 /* return getcwd or $PWD or . */
00129 extern char * Get_Current_Working_Directory (void);
00130 
00131 #ifdef __cplusplus
00132 }
00133 #endif
00134 #endif /* file_util_INCLUDED */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines