batch_file.h File Reference

Describes a single input or output file of a batch job. More...

`#include <errno.h>`
`#include <sys/types.h>`
`#include <dirent.h>`
`#include "sha1.h"`
`#include "list.h"`
`#include "debug.h"`
`#include "path.h"`

Go to the source code of this file.

## Data Structures

struct | batch_file
| Internal description of a single file used by a batch job. More...

## Functions

struct batch_file * | batch_file_create (const char *outer_name, const char *inner_name)
| Create batch_file struct.
void | batch_file_delete (struct batch_file *f)
| Delete batch_file struct.
char * | batch_file_to_string (struct batch_file *f)
| Output batch_file as a string.
char * | batch_file_list_to_string (struct list *file_list)
| Output list of batch_files as a string.
int | batch_file_outer_compare (struct batch_file *f1, struct batch_file *f2)
| Compare function for comparing batch_files based on outer_name.
char * | batch_file_generate_id (struct batch_file *f)
| Generate a sha1 hash based on the file contents.
char * | batch_file_generate_id_dir (char *file_name)
| Generates a sha1 hash based on the directory's contents.

## Detailed Description

Describes a single input or output file of a batch job.

For each input/output file consumed/produced by a single batch_job, a batch_file object describes the name of the file as the submitter sees it (outer_name) and the intended name of the file as seen by the running job (inner_name). Many (but not all) batch systems execute jobs in a sandbox that permits these two names to be different. Some batch systems do not permit these names to differ.

## Function Documentation

## batch_file_create()

struct batch_file * batch_file_create | ( | const char * | outer_name,
|  | const char * | inner_name )

Create batch_file struct.

Parameters

  outer_name | A pointer to the file's name host/submission side.
  inner_name | A pointer to the file's name execution side.

Returns
  batch_file struct.

## batch_file_delete()

void batch_file_delete | ( | struct batch_file * | f | ) |

Delete batch_file struct.

This includes freeing host_name and exe_name if defined.

Parameters

  file | A batch_file struct to be deleted.

## batch_file_to_string()

char * batch_file_to_string | ( | struct batch_file * | f | ) |

Output batch_file as a string.

Format is "outer_name=inner_name" when renaming is needed. and just "outer_name" when it is not.

Parameters

  file | A batch_file struct to be stringified.

Returns
  pointer to char * representing the flattened list.

## batch_file_list_to_string()

char * batch_file_list_to_string | ( | struct list * | file_list | ) |

Output list of batch_files as a string.

Format is "FILE,FILE,...,FILE" where file is the result of batch_file_to_string.

Parameters

  files | A list struct containing batch_file structs.

Returns
  pointer to char * representing the flattened list.

## batch_file_outer_compare()

int batch_file_outer_compare | ( | struct batch_file * | f1,
|  | struct batch_file * | f2 )

Compare function for comparing batch_files based on outer_name.

Parameters

  file1 | First file to compare.
  file2 | Second file to compare.

Returns
  Relative alphabetic order of files outer_name's

## batch_file_generate_id()

char * batch_file_generate_id | ( | struct batch_file * | f | ) |

Generate a sha1 hash based on the file contents.

Parameters

  f | The batch_file whose checksum will be generated.

Returns
  Allocated string of the hash, user should free or NULL on error of checksumming file.

## batch_file_generate_id_dir()

char * batch_file_generate_id_dir | ( | char * | file_name | ) |

Generates a sha1 hash based on the directory's contents.

Parameters

  file_name | The directory that will be checked

Returns
  Allocated string of the hash, user should free or NULL on error scanning the directory.