Skip to content
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

adding file.temp_file to eldritch #797

Merged
merged 8 commits into from
Aug 15, 2024
Merged

adding file.temp_file to eldritch #797

merged 8 commits into from
Aug 15, 2024

Conversation

adm1nPanda
Copy link
Collaborator

What type of PR is this?

/feature
/kind eldritch-function

What this PR does / why we need it:

Implemented file.temp_file()

Which issue(s) this PR fixes:

Fixes #788

@adm1nPanda adm1nPanda requested a review from hulto August 6, 2024 04:37
Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

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

Oops sorry @adm1nPanda i should have been more clear in the issue description.
For this feature we'd like to leverage the OSes default tmp system.
/tmp/ on linux, /var/private/tmp/*/*/* on mac, C:\Users\AppData\Local\Temp (i think) on Windows. You shouldn't need to specify the tmp dir path the library should handle that for you.

To do this we can leverage the temp file library we've been using and it looks like the .keep() call you're making is exactly what we need.

Instead of a random file name in a specified dir i'd like to create a tmp file in and optionally specify the name of that file.

The file should be empty and the function should return the path to the newly created file.

Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

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

Awesome! Just a couple changes then should be good 🤌

implants/lib/eldritch/src/file/temp_file_impl.rs Outdated Show resolved Hide resolved
implants/lib/eldritch/src/file/temp_file_impl.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

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

Clarified how to do optional parameters.

This way lets users do something like:

tmp_file = file.temp()
# - or -
name_tmp_file = file.temp("special_name.txt")

Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

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

Couple nits that you can ignore if you want.
One small change please.

implants/lib/eldritch/src/file/temp_file_impl.rs Outdated Show resolved Hide resolved
implants/lib/eldritch/src/file/temp_file_impl.rs Outdated Show resolved Hide resolved
implants/lib/eldritch/src/file/temp_file_impl.rs Outdated Show resolved Hide resolved
hulto
hulto previously approved these changes Aug 13, 2024
Copy link
Collaborator

@hulto hulto left a comment

Choose a reason for hiding this comment

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

Nice!
Some optional nits if you want but this looks good to me! 🙂

implants/lib/eldritch/src/file/temp_file_impl.rs Outdated Show resolved Hide resolved
implants/lib/eldritch/src/file/temp_file_impl.rs Outdated Show resolved Hide resolved
hulto
hulto previously approved these changes Aug 14, 2024
implants/lib/eldritch/src/file/temp_file_impl.rs Outdated Show resolved Hide resolved
@adm1nPanda adm1nPanda merged commit 3008866 into main Aug 15, 2024
6 checks passed
@adm1nPanda adm1nPanda deleted the eldritch-file-temp branch August 15, 2024 02:46
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.

Eldritch implementfile.tmp_file
2 participants