Skip to content

How to read from and write to files under the same directory? #206

@yanshay

Description

@yanshay

I want to read content from a file in the root folder and write content from there to files in the same volume at different levels of the folder hierartchy (so under the same root directory).

For that if I get it right, I need to open the root folder, open the file, then change directory and open file for write and write.

However, once the file is open (and I don't close it since I'm processing it), I can't change_dir (can't borrow the dir as mutable because it's borrowed for the open file).

So how can this be done?

Should I open a second instance of the root folder and change from there?
What if I close the root folder of the second instance? will it close also the first? Or are these just two instances of the same folder that work separately? But then what happens if in one I add files? Will the other reflect that?

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