Added some small modifications

This commit is contained in:
2024-02-18 02:06:49 +01:00
parent dcdec67476
commit 1ff4d4df2f
5 changed files with 63 additions and 3 deletions

View File

@@ -68,3 +68,18 @@ Status GetBackingDiskPath(const char* backing_identifier, char** _backing_path)
return status;
}
Status DoesBackingExist(const char* backing_identifier, bool* _result) {
// Get the backing path
char* backing_path = NULL;
Status status = GetBackingDiskPath(backing_identifier, &backing_path);
if (status != SUCCESS)
return status;
// Check if the backing exists and is a regular file
struct stat st;
*_result = stat(backing_path, &st) == 0 && S_ISREG(st.st_mode);
free(backing_path);
return SUCCESS;
}