int write_file(const unsigned char *buffer, const size_t len, const char *path) {
    errno = 0;
    FILE *file = fopen(path, "wb");
    if (file == NULL) {
        int errsv = errno;
        printf("Could not open file for writing: %s (%s)\n", path, strerror(errsv));
        return ERROR;
    }
    size_t n = fwrite(buffer, 1, len, file);
    if (n != len) {
        int errsv = errno;
        printf("Error writing to file: %s (%s)\n", path, strerror(errsv));
        fclose(file);
        return ERROR;
    }
    fclose(file);
    return SUCCESS;
}
int write_file(const unsigned char *buffer, const size_t len, const char *path) {
    errno = 0;
    FILE *file = fopen(path, "wb");
    if (file == NULL) {
        int errsv = errno;
        printf("Could not open file for writing: %s (%s)\n", path, strerror(errsv));
        return ERROR;
    }
    size_t n = fwrite(buffer, 1, len, file);
    if (n != len) {
        int errsv = errno;
        printf("Error writing to file: %s (%s)\n", path, strerror(errsv));
        fclose(file);
        return ERROR;
    }
    fclose(file);
    return SUCCESS;
}