Skip to content

Implement -fprintf #383

Closed
Closed

Description

@hanbings

refer: https://www.gnu.org/software/findutils/manual/html_node/find_html/Print-File-Information.html

Action: -fprintf file format
True; like ‘-printf’ but write to file like ‘-fprint’. 
The output file is always created, even if no output is ever sent to it.

-fprint see Print File Name

Activity

  1. keys-i commented on Jun 29, 2024

    @keys-i

    is print in printer.rs?

  2. hanbings commented on Jun 29, 2024

    @hanbings
    CollaboratorAuthor

    Oh, I'm sorry for overlooking this. -printf has been implemented. thanks :)

  3. changed the title [-]Implement `-printf` and `-fprintf`[/-] [+]Implement `-fprintf`[/+] on Jun 29, 2024
  4. keys-i commented on Jun 29, 2024

    @keys-i

    Could you point me where because from what I read they seem to have similar implementation

  5. keys-i commented on Jun 29, 2024

    @keys-i

    I would to try and improve cuz I want more rust in Debian

  6. cakebaker commented on Jun 29, 2024

    @cakebaker
    Contributor

    Could you point me where because from what I read they seem to have similar implementation

    Have a look at matchers/printf.rs.

  7. hanbings commented on Jun 29, 2024

    @hanbings
    CollaboratorAuthor

    Could you point me where because from what I read they seem to have similar implementation

    Sorry for the late reply.

    In simple terms, -fprintf is an implementation of -printf that directs output to a file and -printf is implemented in printf.rs(https://github.com/uutils/findutils/blob/main/src/find/matchers/printf.rs).
    Here is a detailed description of -fprintf: Print File Name

    Some information that might be helpful:

    • The general structure of find starts from src/find, with main.rs as the entry point, and then to src/find/matcher/mod.rs to parse the command line parameters. Then other files in src/find/matcher are responsible for processing and determining whether a file meets the requirements of the command line parameters, and finally using the write! macro to output.

    • Use the write! macro for output.

      let mut out = matcher_io.deps.get_output().borrow_mut();
      write!(out, "content").unwrap();
  8. keys-i commented on Jul 1, 2024

    @keys-i

    the thing im confused about is

  9. keys-i commented on Jul 1, 2024

    @keys-i

    should i make a new file for fprintf or just have a function since most the functionaluity is the same

  10. hanbings commented on Jul 1, 2024

    @hanbings
    CollaboratorAuthor

    should i make a new file for fprintf or just have a function since most the functionaluity is the same

    I guess yes, making the modification in the printf.rs file might use less code. For example, add an Option<Path> field to the Printf(https://github.com/uutils/findutils/blob/main/src/find/matchers/printf.rs#L600) structure and switch different outputs in write!() depending on whether Option has data.

    What are your thoughts on this? :) @cakebaker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions