mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-05 02:29:28 +02:00
add a function to check if a given path is in the blob-directory
This commit is contained in:
parent
6072d73b08
commit
d7cd9c0b1e
2 changed files with 17 additions and 2 deletions
|
@ -1429,6 +1429,21 @@ void dc_make_rel_path(dc_context_t* context, char** path)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a path describes a file in the blob directory.
|
||||
* The path can be give absolute or relative (starting with `$BLOBDIR`).
|
||||
* The function does not check if the file really exists.
|
||||
*/
|
||||
int dc_is_in_blobdir(dc_context_t* context, const char* path)
|
||||
{
|
||||
if ((strncmp(path, context->blobdir, strlen(context->blobdir))==0)
|
||||
|| (strncmp(path, "$BLOBDIR", 8)==0)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy a file to the blob directory, if needed.
|
||||
*
|
||||
|
@ -1447,8 +1462,7 @@ int dc_make_rel_and_copy(dc_context_t* context, char** path)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((strncmp(*path, context->blobdir, strlen(context->blobdir))==0)
|
||||
|| (strncmp(*path, "$BLOBDIR", 8)==0)) {
|
||||
if (dc_is_in_blobdir(context, *path)) {
|
||||
dc_make_rel_path(context, path);
|
||||
success = 1; // file is already in blobdir
|
||||
goto cleanup;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue