GLYLIB  0.3.0b
file_directory_status_utils.c
Go to the documentation of this file.
00001 /** \file 0u.check_fd_status.c  Utilities for checking the existence, 
00002         size and/or other attributes of a file or directory. 
00003 */
00004 
00005 #include <mylib.h>
00006 #include <gly_fileutils.h>
00007 
00008 
00009 /****************** check_file_existence() ******************/
00010 /** Figures out whether a file exists, but that's all. 
00011 
00012 Name is the name, including path if needed, of the file
00013 to check. 
00014 */
00015 
00016 ///  START HERE
00017 // uhm.... this won't work...
00018 
00019 int check_file_existence(const char *Name){
00020 //int status=0;
00021 ///return status;
00022 fprintf(stderr,"ERROR!  The file check_file_existence doesn't work.  Rewrite it or don't use it.\n");
00023 return -1;
00024 }
00025 
00026 /****************** check_directory_existence() ******************/
00027 /** Figures out whether a directory exists, but that's all. 
00028 
00029 Name is the name, including path if needed, of the directory 
00030 to check. 
00031 */
00032 
00033 ///  START HERE
00034 // uhm.... this won't work...
00035 
00036 int check_directory_existence(const char *Name){
00037 //int status=0;
00038 //return status;
00039 fprintf(stderr,"ERROR!  The file check_directory_existence doesn't work.  Rewrite it or don't use it.\n");
00040 return -1;
00041 }
00042 
00043 /*************** gly_get_current_working_directory() **************/
00044 /** Returns a pointer to a string corresponding to the current working 
00045 directory.  
00046 
00047 Typical usage:
00048 
00049 char *myCWD;
00050 
00051 myCWD=strdup(gly_get_current_working_directory());
00052 */
00053 const char *gly_get_current_working_directory(void){
00054 char *dirstr;
00055 int sz=250;
00056 dirstr=(char*)calloc(sz,sizeof(char));
00057 while(getcwd(dirstr, 250)==NULL){
00058         if(sz>5000) {mywhine("Unbelievably long (> 5000 chars) current working directory string\n\tfound in gly_get_current_working_directory.");}
00059         sz+=50;
00060         dirstr=realloc(dirstr,sz*(sizeof(char))); } 
00061 return dirstr;
00062 }
 All Classes Files Functions Variables Typedefs Defines