69 if (
streq(filename,
"-"))
71 else if (access(filename,R_OK) == 0)
85 if (
streq(filename,
"-"))
87 else if (access(filename,W_OK) == 0)
89 else if ((access(filename,F_OK) == -1) &&
104 if ((fd = fopen(tmpname,
"wb")) ==
NULL)
106 cerr <<
"Write access failed for temporary file\n";
109 while ((n=fread(buff,1,1024,stdin)) > 0)
110 if (fwrite(buff,1,n,fd) != n)
112 cerr <<
"Write error on temporary file";
125 d = strtol(s, &a, 0);
126 success = (*a ==
'\0') ? 0: 1;
136 d = strtol(s, &a, 0);
145 sprintf(tmp,
"%d", n);
156 sprintf(spec,
"%%%d.%df", width, pres);
158 sprintf(spec,
"%%.%df", pres);
159 sprintf(tmp, spec, n);
178 full = full.
before(
".", -1);
197 if (quote_char(0) == s(0))
199 if (quote_char(0) == s(s.
length()-1))
209 EST_String sysstr = prog_name +
" " + filename +
" > " + new_filename;
212 int stat = system(sysstr);
226 return system(prog_name +
" " + filename);
235 if(new_filename ==
"-")
236 sysstr = prog_name +
" " + filename;
238 sysstr = prog_name +
" " + filename +
" > " + new_filename;
239 return system(sysstr);
int readable_file(char *filename)
return true if this file is readable
int writable_file(char *filename)
return true if this file is writeable
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
Utility IO Function header file.
char * cmake_tmp_filename()
EST_String itoString(int n)
Make a EST_String object from an integer.
size_t index(const char *s, ssize_t pos=0) const
Position of substring (starting at pos)
EST_String make_tmp_filename()
Make a unique temporary filename.
EST_String ftoString(float n, int pres, int width, int right_justify)
Make a EST_String object from an float, with variable precision.
int Stringtoi(EST_String s, int &success)
int compress_file_in_place(const EST_String &filename, const EST_String &prog_name)
Uncompress file and over-write existing file with uncompressed version.
EST_String uncompress_file_to_temporary(const EST_String &filename, const EST_String &prog_name)
Uncompress file by calling program prog, and write it to new tempoary file. Return name of temporary ...
EST_String basename(EST_String full, EST_String ext)
This acts like the bourne shell basename command. By default, it strips any leading path from a strin...
EST_String stdin_to_file()
Copy stdin to a file and return the name of that tmpfile.
int delete_file(const EST_String &filename)
OS independent way of removing a file.
int compress_file(const EST_String &filename, const EST_String &new_filename, const EST_String &prog_name)
compress file by calling program prog, writing result to new_filename
size_t length(void) const
Length of string ({not} length of underlying chunk)
void strip_quotes(EST_String &s, const EST_String quote_char)
remove quotes from a string
EST_String after(int pos, int len=1) const
Part after pos+len.
EST_String before(int pos, int len=0) const
Part before position.
Utility EST_String Functions header file.