46 #include "EST_types.h"
47 #include "EST_String.h"
48 #include "EST_Pathname.h"
51 #include "EST_cutils.h"
52 #include "EST_Token.h"
57 char *tname = cmake_tmp_filename();
67 if (streq(filename,
"-"))
69 else if (access(filename,R_OK) == 0)
83 if (streq(filename,
"-"))
85 else if (access(filename,W_OK) == 0)
87 else if ((access(filename,F_OK) == -1) &&
102 if ((fd = fopen(tmpname,
"wb")) == NULL)
104 cerr <<
"Write access failed for temporary file\n";
107 while ((n=fread(buff,1,1024,stdin)) > 0)
108 if (fwrite(buff,1,n,fd) != n)
110 cerr <<
"Write error on temporary file";
122 d = strtol(s, &a, 0);
123 success = (*a ==
'\0') ? 0: 1;
134 d = strtol(s, &a, 0);
135 success = (*a ==
'\0') ? 0: 1;
144 sprintf(tmp,
"%d", n);
161 sprintf(tmp, spec, n);
180 full = full.
before(
".", -1);
199 if (quote_char(0) == s(0))
201 if (quote_char(0) == s(s.
length()-1))
211 EST_String sysstr = prog_name +
" " + filename +
" > " + new_filename;
214 int stat = system(sysstr);
228 return system(prog_name +
" " + filename);
237 if(new_filename ==
"-")
238 sysstr = prog_name +
" " + filename;
240 sysstr = prog_name +
" " + filename +
" > " + new_filename;
241 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
Utility IO Function header file.
int index(const char *s, int pos=0) const
Position of substring (starting at pos)
EST_String itoString(int n)
Make a EST_String object from an integer.
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 compress_file_in_place(const EST_String &filename, const EST_String &prog_name)
Uncompress file and over-write existing file with uncompressed version.
int Stringtoi(EST_String s)
Make an int from a EST_String. EST_String equivalent of atoi()
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 ...
int length(void) const
Length of string ({not} length of underlying chunk)
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
int contains(const char *s, int pos=-1) const
Does it contain this substring?
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.