Skip to content

feat: Adds support for Reader to_folder method #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

gpeacock
Copy link
Contributor

This only works for file paths, there is currently no streaming equivalent.
Writes the manifest.json and all resource, under associated manifest label folders.

@gpeacock gpeacock requested a review from tmathern February 21, 2025 01:03
@@ -465,6 +465,33 @@ pub unsafe extern "C" fn c2pa_reader_resource_to_stream(
}
}

/// Writes all the resources in a Reader to a folder.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Writes all the resources in a Reader to a folder.
/// Writes all the resources from a Reader to a folder.

Your non-native reviewer got confused by the wording, but maybe my grammer is off.

/// Writes all the resources in a Reader to a folder.
///
/// # Parameters
/// * reader_ptr: pointer to a Reader.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to add if the memory pointed to is actually modified or used read-only.
Here it's read-only, so not sure if it's worth adding?

Ok(_) => 0,
Err(err) => {
Error::from_c2pa_error(err).set_last();
-1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not saying we should, but we could return more precise error codes in the future (not for this PR).

@@ -104,7 +104,7 @@ TEST(Builder, SignStream)
dest.seekp(0, std::ios::beg);
auto reader = c2pa::Reader("image/jpeg", dest);
auto json = reader.json();
ASSERT_TRUE(json.find("c2pa.training-mining") != std::string::npos);
ASSERT_TRUE(json.find("cawg.training-mining") != std::string::npos);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack -
But our test cases could also have both during the transition period.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants