My Project
Functions
backup.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include "include/backup.h"
#include "include/substitutions.h"
Include dependency graph for backup.c:

Functions

int backupExistingFile (char *filename, char *backup_ext, char *status)
 
int fileCopy (char *filename1, char *filename2, char *status)
 

Function Documentation

◆ backupExistingFile()

int backupExistingFile ( char *  filename,
char *  backup_ext,
char *  status 
)

Check if specified file exists; rename existing file to a backup file. If also backup file exists, then remove that.

Returns
Returns 0, if successful, and <> in case of an error.
Parameters
filenameName of file which, if it exists, is renamed to a backup file
backup_extExtension for backup file; NULL will set the default ".bak" extension.
statusPointer to a string (allocated for at least 64 chars) where error message or other execution status will be written; enter NULL, if not needed

◆ fileCopy()

int fileCopy ( char *  filename1,
char *  filename2,
char *  status 
)

Copy file contents to another file. Existing file will be overwritten, to prevent it call backupExistingFile() before calling this function.

Returns
Returns 0 if successfull, otherwise >0.
Parameters
filename1Name of file to be copied
filename2Name of new file
statusPointer to a string (allocated for at least 64 chars) where error message or other execution status will be written; enter NULL, if not needed