1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add HRN_STORAGE_COPY() macro.

This commit is contained in:
Cynthia Shang 2021-06-24 14:01:03 -04:00 committed by David Steele
parent 50c129ae9d
commit d0f3a3f2af
2 changed files with 47 additions and 0 deletions

View File

@ -361,6 +361,32 @@ hrnStorageMove(
hrnTestResultEnd();
}
/**********************************************************************************************************************************/
void
hrnStorageCopy(
const Storage *const storageSource, const char *const fileSource, const Storage *const storageDest, const char *const fileDest,
HrnStorageCopyParam param)
{
hrnTestResultBegin(__func__, false);
ASSERT(storageSource != NULL);
ASSERT(fileSource != NULL);
ASSERT(storageDest != NULL);
ASSERT(fileDest != NULL);
const String *const fileSourceStr = storagePathP(storageSource, STR(fileSource));
const String *const fileDestStr = storagePathP(storageDest, STR(fileDest));
printf("copy '%s' to '%s'", strZ(fileSourceStr), strZ(fileDestStr));
hrnTestResultComment(param.comment);
// Copy the file
storageCopyP(storageNewReadP(storageSource, fileSourceStr), storageNewWriteP(storageDest, fileDestStr));
hrnTestResultEnd();
}
/**********************************************************************************************************************************/
void
hrnStoragePut(

View File

@ -120,6 +120,27 @@ typedef struct HrnStorageMoveParam
void hrnStorageMove(
const Storage *const storage, const char *const fileSource, const char *const fileDest, HrnStorageMoveParam param);
/***********************************************************************************************************************************
Copy a file
***********************************************************************************************************************************/
typedef struct HrnStorageCopyParam
{
VAR_PARAM_HEADER;
const char *comment; // Comment
} HrnStorageCopyParam;
#define HRN_STORAGE_COPY(storageSource, fileSource, storageDest, fileDest, ...) \
do \
{ \
hrnTestLogPrefix(__LINE__); \
hrnStorageCopy(storageSource, fileSource, storageDest, fileDest, (HrnStorageCopyParam){VAR_PARAM_INIT, __VA_ARGS__}); \
} \
while (0)
void hrnStorageCopy(
const Storage *const storageSource, const char *const fileSource, const Storage *const storageDest, const char *const fileDest,
HrnStorageCopyParam param);
/***********************************************************************************************************************************
Create a path
***********************************************************************************************************************************/