openage icon indicating copy to clipboard operation
openage copied to clipboard

Temporary file/directory support

Open heinezen opened this issue 2 years ago • 5 comments

Required Skills: Python or C++

Difficulty: Easy

It would be nice if we could create temporary files/directories in our current file system abstraction API. We currently only use temporary structures in the converter, but they could be useful in other places, e.g. for unzipping archives or on-disk caching.

Creation of temporary files could be implemented in our Python file API or our C++ file API or in both. The Python-side implementation is more preferrable at the moment, since the converter is written Python and temporary files already have an active use case there.

The easiest way to implement support probably is to add a method that calls the underlying system libraries for temporary file/directory creation:

  • Python: tempfile module
  • C++: std::filesystem and std::tmpfile

The retrieved path is then wrapped in our Path/Directory classes and returned by the method.

Tasks:

  • [X] Create temp file/dir and wrap them in openage file system API (Python)
  • [ ] Create temp file/dir and wrap them in openage file system API (C++)
  • [ ] Delete temp file/dir explicitely when object is destroyed
  • [ ] Use new implementation in code (currently only in converter)
  • [ ] (optional) Add method for checking if a file/dir is temporary

Further Reading

heinezen avatar Sep 17 '23 14:09 heinezen

Hey @heinezen , I'm interested in working with this issue. I'm new to open source but I've beginner level experience in working with Python and C++ both. Can you please assign me this issue.

And also can you please elaborate more about the tasks that exactly what I've to do. Thanks for your cooperation :)

Ashhar-24 avatar Oct 29 '23 07:10 Ashhar-24

@Ashhar-24 Hey, I assigned you to to the issue nw :)

Most of what we want from the task should be in the issue description already. The general goal is to make temporary file creation/access more easier than it is right now.

For a start, I think you should try out these steps:

  1. Compile and run the project one if you haven't already. Development works much better when you can test your own code :D
  2. Look at the current usage of tempfile in our code, e.g. https://github.com/SFTtech/openage/blob/821a6d1a46e2ff7c5f66eeb34d9ece983e9c03b8/openage/convert/tool/subtool/acquire_sourcedir.py#L253-L295
  3. openage has its own path interface that acts as a wrapper around system paths. It should be extended to get tempfile support. I think the easiest way to implement it in there is to add a staticmethod that first creates a temporary file using tempfile, then wraps it in our Path object and returns the reulting Path.

I think this should give you a good idea how to start. If you get stuck, you can ask more questions in the Matrix chat.

heinezen avatar Oct 29 '23 13:10 heinezen

Hey @heinezen , I'm interested in working with this issue. I'm new to open source but I've 10+ experience Python and C++ both. I see some of the tasks in this issue are still open. Can I work on this issue ?

Thank you :)

viswes31 avatar Apr 15 '24 13:04 viswes31

go for it!

TheJJ avatar Apr 15 '24 17:04 TheJJ

@viswes31 Everything from the tasklist that's not ticked is still up for grabs ^^

heinezen avatar Apr 15 '24 20:04 heinezen