GLYLIB  0.3.0b
FILE_UTILS

Classes

struct  gly_keysvals
struct  fileset
struct  fileslurp
 A structure for a function similar to the perl notion of "slurping" a file. More...

Functions

FILE * myfopen (const char *Name, const char *option)
 Opens a file with error checking.
FILE * myfreopen (const char *Name, const char *, FILE *option)
void read_eek (const char *surprise, const char *FileDesc)
 Complains (EEK!!!) if a file read fails.
void read_neek (const char *surprise, int line, int field)
 Complains (EEK!!!) if a file read fails.
void read_fneek (const char *surprise, int line, int field, const char *FILENAME)
int sscan_file (FILE *F, const char *str)
 Scans a file for instances of a string.
int cscan_file (FILE *F, char c)
fileslurp slurp_file (fileset F)
const char * gly_get_current_working_directory (void)
gly_keysvals get_keysvals_from_slurp (fileslurp F, const char *SEP, int newline_sep, int ignore_hash)
gly_keysvals get_keysvals_from_file (fileset F, const char *SEP, int newline_sep, int ignore_hash)

Detailed Description

< Required for directory manipulations Required for directory manipulations Required to get the current working directory


Function Documentation

int cscan_file ( FILE *  F,
char  c 
)

Returns the number of times the character c is found in file F

Definition at line 25 of file scan_file.c.

gly_keysvals get_keysvals_from_file ( fileset  F,
const char *  SEP,
int  newline_sep,
int  ignore_hash 
)

This is like get_keysvals_from_slurp (see) except it uses a file and not a fileslurp.

In fact, this function merely slurps in your file and then calls get_keysvals_from_slurp

Reads in keyword/value pairs from a file, drops them in a structure designed for the purpose.

< Slurp file

< Call the slurp version...

Definition at line 75 of file get_keysvals.c.

References get_keysvals_from_slurp(), and slurp_file().

Here is the call graph for this function:

gly_keysvals get_keysvals_from_slurp ( fileslurp  F,
const char *  SEP,
int  newline_sep,
int  ignore_hash 
)

Reads in keyword/value pairs from a file, drops them in a structure designed for the purpose.

Some notes:

  • If ignore_hash is 0, everything from a hash mark (#) to the end of the line is ignored.
  • Any line not containing the separator SEP is ignored.
  • Keywords and values may not be separated by a newline.
  • If newline_sep is set to zero, everything* from the start of the line to the first instance of SEP will be regarded as the KEYWORD and everything* from the first instance of SEP to the end of the line will be regarded as the VALUE. *Intial and final whitespace will be removed from both keyword and value, but all else, including internal whitespace, will be retained.
  • If newline_sep is not set to zero, neither keywords nor values may contain whitespace.
  • SEP should be passed as a string complete with a null terminator.

< counter

< temporary pointer

< Loop through the slurp

< See if there is a hash in this line

< If there is a hash, call that the end of the string

< If no separator this line, ignore it

< If newline_sep is set

< Split string at SEP (find with strstr)

< Set end of the keyword string

< Prune whitespace and copy to K

< Move pointer to the end of the separator

< Prune whitespace and copy to V

Else

  • Grab K
  • Check for SEP
  • Grab V --- Allow for line-crossing? No!!! (what a pain...)

Definition at line 28 of file get_keysvals.c.

References gly_keysvals::K, fileslurp::L, gly_keysvals::n, fileslurp::n, prune_string_whitespace(), and gly_keysvals::V.

Referenced by get_keysvals_from_file().

Here is the call graph for this function:

Here is the caller graph for this function:

const char* gly_get_current_working_directory ( void  )

Determines the current working directory.

Returns a pointer to a string corresponding to the current working directory.

Typical usage:

char *myCWD;

myCWD=strdup(gly_get_current_working_directory());

Definition at line 53 of file file_directory_status_utils.c.

References mywhine().

Here is the call graph for this function:

FILE* myfopen ( const char *  Name,
const char *  option 
)

Opens a file with error checking.

List of files and directories generated for each state. Opens a file with error checking. This function will open a file and then check to see if the file actually opened. If not, it will write a descriptive error message and exit(1) the program. Doing this saves many, many core dumps.

Definition at line 6 of file myfopen.c.

Referenced by crdsnaps(), load_atypes(), load_pdb(), outputAsmblPDB(), outputMolPDB(), read_amber_prmtop_asis(), slurp_file(), and write_amber_prmtop().

Here is the caller graph for this function:

FILE* myfreopen ( const char *  Name,
const char *  ,
FILE *  option 
)

Like myfopen, but the freopen version.

Definition at line 25 of file myfopen.c.

Referenced by read_amber8_mden(), and read_prep().

Here is the caller graph for this function:

void read_eek ( const char *  surprise,
const char *  FileDesc 
)

Complains (EEK!!!) if a file read fails.

Complains (EEK!!!) if a file read fails. Prints the following: "

Unexpected surprise during read of file FileDesc.

Exiting.

"

Definition at line 6 of file read_eek.c.

Referenced by load_atypes(), load_dlg_mol(), read_amber_prmtop_asis(), and read_prepres().

Here is the caller graph for this function:

void read_fneek ( const char *  surprise,
int  line,
int  field,
const char *  FILENAME 
)

Complains (EEK!!!) if a file read fails.

Definition at line 18 of file read_neek.c.

Referenced by read_amber_prmtop_asis().

Here is the caller graph for this function:

void read_neek ( const char *  surprise,
int  line,
int  field 
)

Complains (EEK!!!) if a file read fails.

Complains (EEK!!!) if a file read fails. Prints the following: "

"

Definition at line 7 of file read_neek.c.

Referenced by rwm_line(), and rwm_line_char().

Here is the caller graph for this function:

Slurps in the contents of an entire file or directory

Definition at line 19 of file fileslurp.c.

References fileset::F, fileslurp::L, line, myfopen(), fileset::N, and fileslurp::n.

Referenced by get_keysvals_from_file(), and load_dlg_mol().

Here is the call graph for this function:

Here is the caller graph for this function:

int sscan_file ( FILE *  F,
const char *  str 
)

Scans a file for instances of a string.

Returns the number of times the string str is found in file F

Definition at line 7 of file scan_file.c.

 All Classes Files Functions Variables Typedefs Defines